Skip to content

Commit

Permalink
cache-and-network
Browse files Browse the repository at this point in the history
  • Loading branch information
liangfung committed Mar 20, 2024
1 parent 3739197 commit f5772f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ const NetworkForm: React.FC<NetworkFormProps> = ({
}

export const GeneralNetworkForm = () => {
const [{ data, stale }, reexecuteQuery] = useNetworkSetting({
requestPolicy: 'network-only'
})
const [{ data, stale }, reexecuteQuery] = useNetworkSetting()

const onSuccess = () => {
toast.success('Network configuration is updated')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,8 @@ function buildListValuesFromField(fieldListValue?: Array<{ value: string }>) {
}

export const GeneralSecurityForm = () => {
const [{ data }, reexecuteQuery] = useQuery({
query: securitySetting,
requestPolicy: 'network-only'
const [{ data, stale }, reexecuteQuery] = useQuery({
query: securitySetting
})
const onSuccess = () => {
toast.success('Security configuration is updated')
Expand All @@ -242,7 +241,7 @@ export const GeneralSecurityForm = () => {
)
}

return data ? (
return data && !stale ? (
<SecurityForm defaultValues={defaultValues} onSuccess={onSuccess} />
) : (
<FormSkeleton />
Expand Down
8 changes: 3 additions & 5 deletions ee/tabby-ui/lib/hooks/use-network-setting.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { useQuery, UseQueryArgs } from 'urql'
import { useQuery } from 'urql'

import { graphql } from '../gql/generates'
import { isClientSide } from '../utils'
Expand All @@ -12,10 +12,8 @@ const networkSettingQuery = graphql(/* GraphQL */ `
}
`)

const useNetworkSetting = (
options?: Pick<UseQueryArgs, 'requestPolicy' | 'pause'>
) => {
return useQuery({ query: networkSettingQuery, ...options })
const useNetworkSetting = () => {
return useQuery({ query: networkSettingQuery })
}

const useExternalURL = () => {
Expand Down

0 comments on commit f5772f2

Please sign in to comment.