From f9d1e9f0bc9fd2dd3352d960f49dea580659f86f Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Wed, 6 Mar 2024 15:25:20 +0800 Subject: [PATCH] fix: graph collection postions data missing (#3627) --- .../src/client/GraphDrawPage.tsx | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-graph-collection-manager/src/client/GraphDrawPage.tsx b/packages/plugins/@nocobase/plugin-graph-collection-manager/src/client/GraphDrawPage.tsx index 77521af8d..bd54c12da 100644 --- a/packages/plugins/@nocobase/plugin-graph-collection-manager/src/client/GraphDrawPage.tsx +++ b/packages/plugins/@nocobase/plugin-graph-collection-manager/src/client/GraphDrawPage.tsx @@ -432,13 +432,6 @@ export const GraphDrawPage = React.memo(() => { }; const dataSource = useDataSource(); - useEffect(() => { - dataSource.addReloadCallback(reloadCallback); - - return () => { - dataSource.removeReloadCallback(reloadCallback); - }; - }, []); const initGraphCollections = () => { targetGraph = new Graph({ @@ -1081,29 +1074,32 @@ export const GraphDrawPage = React.memo(() => { }; }, []); + useEffect(() => { + dataSource.addReloadCallback(reloadCallback); + + return () => { + dataSource.removeReloadCallback(reloadCallback); + }; + }, []); useEffect(() => { setLoading(true); refreshPositions() .then(async () => { - await reloadCallback(); + if (selectedCollections && collectionList.length) { + const selectKeys = selectedCollections?.split(','); + const data = collectionList.filter((v) => selectKeys.includes(v.name)); + renderInitGraphCollection(data, false); + handelResetLayout(true); + targetGraph.selectedCollections = selectedCollections; + } else { + !selectedCollections && reloadCallback(true); + } setLoading(false); }) .catch((err) => { setLoading(false); throw err; }); - }, []); - - useEffect(() => { - if (selectedCollections && collectionList.length) { - const selectKeys = selectedCollections?.split(','); - const data = collectionList.filter((v) => selectKeys.includes(v.name)); - renderInitGraphCollection(data, false); - handelResetLayout(true); - targetGraph.selectedCollections = selectedCollections; - } else { - !selectedCollections && reloadCallback(true); - } return () => { cleanGraphContainer(); };