From c0235cdd0abc029c734d2913a2b6bac9654d4562 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Fri, 11 Mar 2022 19:38:17 +0800 Subject: [PATCH] fix: only fetch wiki tocs with wikiId change --- packages/client/src/components/wiki/tocs/index.tsx | 2 +- packages/client/src/components/wiki/tocs/tree.tsx | 1 - packages/client/src/data/wiki.tsx | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/client/src/components/wiki/tocs/index.tsx b/packages/client/src/components/wiki/tocs/index.tsx index e0b06a4..28fdb3a 100644 --- a/packages/client/src/components/wiki/tocs/index.tsx +++ b/packages/client/src/components/wiki/tocs/index.tsx @@ -41,7 +41,7 @@ export const WikiTocs: React.FC = ({ data: tocs, loading: tocsLoading, error: tocsError, - } = useWikiTocs(wikiId, documentId); + } = useWikiTocs(wikiId); const [parentIds, setParentIds] = useState>([]); useEffect(() => { diff --git a/packages/client/src/components/wiki/tocs/tree.tsx b/packages/client/src/components/wiki/tocs/tree.tsx index 166520e..b4caddc 100644 --- a/packages/client/src/components/wiki/tocs/tree.tsx +++ b/packages/client/src/components/wiki/tocs/tree.tsx @@ -89,7 +89,6 @@ export const Tree = ({ ellipsis={{ showTooltip: { opts: { content: label, position: "right" } }, }} - style={{ color: "inherit" }} > {label} diff --git a/packages/client/src/data/wiki.tsx b/packages/client/src/data/wiki.tsx index bb71db9..10a400b 100644 --- a/packages/client/src/data/wiki.tsx +++ b/packages/client/src/data/wiki.tsx @@ -100,12 +100,12 @@ export const useWikiHomeDoc = (wikiId) => { * @param workspaceId * @returns */ -export const useWikiTocs = (wikiId, documentId = null) => { +export const useWikiTocs = (wikiId) => { const { data, error, mutate } = useSWR< Array >( - `/wiki/tocs/${wikiId}/documentId/${documentId}`, - wikiId ? () => HttpClient.get(`/wiki/tocs/${wikiId}`) : null + `/wiki/tocs/${wikiId}`, + (url) => HttpClient.get(url) ); const loading = !data && !error;