mirror of https://github.com/fantasticit/think.git
fix: only fetch wiki tocs with wikiId change
This commit is contained in:
parent
eb49ffa20b
commit
c0235cdd0a
|
@ -41,7 +41,7 @@ export const WikiTocs: React.FC<IProps> = ({
|
||||||
data: tocs,
|
data: tocs,
|
||||||
loading: tocsLoading,
|
loading: tocsLoading,
|
||||||
error: tocsError,
|
error: tocsError,
|
||||||
} = useWikiTocs(wikiId, documentId);
|
} = useWikiTocs(wikiId);
|
||||||
const [parentIds, setParentIds] = useState<Array<string>>([]);
|
const [parentIds, setParentIds] = useState<Array<string>>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -89,7 +89,6 @@ export const Tree = ({
|
||||||
ellipsis={{
|
ellipsis={{
|
||||||
showTooltip: { opts: { content: label, position: "right" } },
|
showTooltip: { opts: { content: label, position: "right" } },
|
||||||
}}
|
}}
|
||||||
style={{ color: "inherit" }}
|
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
|
|
|
@ -100,12 +100,12 @@ export const useWikiHomeDoc = (wikiId) => {
|
||||||
* @param workspaceId
|
* @param workspaceId
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const useWikiTocs = (wikiId, documentId = null) => {
|
export const useWikiTocs = (wikiId) => {
|
||||||
const { data, error, mutate } = useSWR<
|
const { data, error, mutate } = useSWR<
|
||||||
Array<IDocument & { createUser: IUser }>
|
Array<IDocument & { createUser: IUser }>
|
||||||
>(
|
>(
|
||||||
`/wiki/tocs/${wikiId}/documentId/${documentId}`,
|
`/wiki/tocs/${wikiId}`,
|
||||||
wikiId ? () => HttpClient.get(`/wiki/tocs/${wikiId}`) : null
|
(url) => HttpClient.get(url)
|
||||||
);
|
);
|
||||||
const loading = !data && !error;
|
const loading = !data && !error;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue