From 5d5c75905fb0b1846eb1f43085a8c176b9847874 Mon Sep 17 00:00:00 2001 From: Innei Date: Tue, 27 Jun 2023 23:13:03 +0800 Subject: [PATCH] fix: query Signed-off-by: Innei --- src/components/widgets/comment/CommentBox.tsx | 4 ++++ src/providers/root/index.tsx | 2 +- src/providers/root/react-query-provider.tsx | 3 ++- src/utils/query-client.server.ts | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/widgets/comment/CommentBox.tsx b/src/components/widgets/comment/CommentBox.tsx index 65ae02127c..3e0e7d5e0d 100644 --- a/src/components/widgets/comment/CommentBox.tsx +++ b/src/components/widgets/comment/CommentBox.tsx @@ -19,6 +19,7 @@ const createInitialValue = () => ({ text: atom(''), refId: atom(''), }) + const CommentBoxContext = createContext(createInitialValue()) const CommentBoxProvider = (props: PropsWithChildren) => { @@ -33,6 +34,7 @@ const enum CommentBoxMode { 'legacy', 'with-auth', } + export const CommentBox: FC = (props) => { const [mode, setMode] = useState(CommentBoxMode['with-auth']) return ( @@ -75,6 +77,7 @@ const CommentBoxWithAuth = () => { ) } + const CommentAuthedInputSkeleton = () => { const color = 'bg-gray-200/50 dark:bg-zinc-800/50' return ( @@ -89,6 +92,7 @@ const CommentAuthedInputSkeleton = () => { ) } + const CommentAuthedInput = () => { const { user } = useUser() if (!user) return diff --git a/src/providers/root/index.tsx b/src/providers/root/index.tsx index a749aceca6..e9fb64a5f4 100644 --- a/src/providers/root/index.tsx +++ b/src/providers/root/index.tsx @@ -25,13 +25,13 @@ export function Providers({ children }: PropsWithChildren) { return ( <> + {children} - ) diff --git a/src/providers/root/react-query-provider.tsx b/src/providers/root/react-query-provider.tsx index e6b4765e49..53bd727d3a 100644 --- a/src/providers/root/react-query-provider.tsx +++ b/src/providers/root/react-query-provider.tsx @@ -27,7 +27,8 @@ const persister = { export const queryClient = new QueryClient({ defaultOptions: { queries: { - cacheTime: 1000 * 60 * 5, // 5 minutes + staleTime: 1000 * 60 * 5, // 5 minutes + refetchInterval: 1000 * 60 * 5, // 5 minutes refetchOnWindowFocus: false, refetchIntervalInBackground: false, diff --git a/src/utils/query-client.server.ts b/src/utils/query-client.server.ts index 789cdd2d59..8f3a38c513 100644 --- a/src/utils/query-client.server.ts +++ b/src/utils/query-client.server.ts @@ -4,8 +4,8 @@ import { cache } from 'react' const queryClient = new QueryClient({ defaultOptions: { queries: { - // cacheTime: 0, staleTime: 1000 * 3, + cacheTime: 1000 * 3, }, }, })