From 59b5fc3539f673e1d55f0708fed8d1634e05d982 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Thu, 5 May 2022 10:32:30 +0800 Subject: [PATCH] fix: fix get active documents ids --- .../components/wiki/setting/documents/index.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/client/src/components/wiki/setting/documents/index.tsx b/packages/client/src/components/wiki/setting/documents/index.tsx index 015c190..5776904 100644 --- a/packages/client/src/components/wiki/setting/documents/index.tsx +++ b/packages/client/src/components/wiki/setting/documents/index.tsx @@ -16,11 +16,15 @@ interface IProps { export const Documents: React.FC = ({ wikiId }) => { const { data: wiki, loading: wikiLoading, toggleStatus: toggleWorkspaceStatus } = useWikiDetail(wikiId); const { data: tocs, loading } = useWikiTocs(wikiId); - const documents = flattenTree2Array(tocs).map((d) => { - d.label = d.title; - d.value = d.id; - return d; - }); + const documents = useMemo( + () => + flattenTree2Array(tocs).map((d) => { + d.label = d.title; + d.value = d.id; + return d; + }), + [tocs] + ); const [nextStatus, setNextStatus] = useState(''); const isPublic = useMemo(() => wiki && isPublicWiki(wiki.status), [wiki]); const [publicDocumentIds, setPublicDocumentIds] = useState([]); // 公开的 @@ -47,7 +51,6 @@ export const Documents: React.FC = ({ wikiId }) => { }} key={item.label} checked={item.checked} - style={{ height: 52 }} > {item.title} @@ -77,7 +80,7 @@ export const Documents: React.FC = ({ wikiId }) => { if (!documents.length) return; const activeIds = documents.filter((doc) => isPublicDocument(doc.status)).map((doc) => doc.id); setPublicDocumentIds(activeIds); - }, [tocs, documents]); + }, [documents]); return (