From 42e05bec0f8fdec62a0deaea205fb9f0b9cc5d0d Mon Sep 17 00:00:00 2001 From: fantasticit Date: Fri, 27 May 2022 22:02:38 +0800 Subject: [PATCH] client: optimize fetch collector --- packages/client/src/data/collector.tsx | 1 + packages/client/src/pages/index.tsx | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/client/src/data/collector.tsx b/packages/client/src/data/collector.tsx index 33c615f..e11d6da 100644 --- a/packages/client/src/data/collector.tsx +++ b/packages/client/src/data/collector.tsx @@ -31,6 +31,7 @@ export const getCollectedWikis = (cookie = null): Promise = export const useCollectedWikis = () => { const { data, error, isLoading, refetch } = useQuery(CollectorApiDefinition.wikis.client(), getCollectedWikis, { staleTime: 500, + enabled: false, }); useEffect(() => { diff --git a/packages/client/src/pages/index.tsx b/packages/client/src/pages/index.tsx index 7a007c0..3e274c3 100644 --- a/packages/client/src/pages/index.tsx +++ b/packages/client/src/pages/index.tsx @@ -118,7 +118,11 @@ const RecentDocs = () => { const Page: NextPage = () => { const [visible, toggleVisible] = useToggle(false); - const { data: staredWikis, loading, error } = useCollectedWikis(); + const { data: staredWikis, loading, error, refresh } = useCollectedWikis(); + + useEffect(() => { + refresh(); + }, [refresh]); return (