fix: only fetch wiki tocs with wikiId change

This commit is contained in:
fantasticit 2022-03-11 19:38:17 +08:00
parent eb49ffa20b
commit c0235cdd0a
3 changed files with 4 additions and 5 deletions

View File

@ -41,7 +41,7 @@ export const WikiTocs: React.FC<IProps> = ({
data: tocs,
loading: tocsLoading,
error: tocsError,
} = useWikiTocs(wikiId, documentId);
} = useWikiTocs(wikiId);
const [parentIds, setParentIds] = useState<Array<string>>([]);
useEffect(() => {

View File

@ -89,7 +89,6 @@ export const Tree = ({
ellipsis={{
showTooltip: { opts: { content: label, position: "right" } },
}}
style={{ color: "inherit" }}
>
{label}
</Typography.Text>

View File

@ -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<IDocument & { createUser: IUser }>
>(
`/wiki/tocs/${wikiId}/documentId/${documentId}`,
wikiId ? () => HttpClient.get(`/wiki/tocs/${wikiId}`) : null
`/wiki/tocs/${wikiId}`,
(url) => HttpClient.get(url)
);
const loading = !data && !error;