From 142896c41aad676d7f54302efeb66ac69fb4c819 Mon Sep 17 00:00:00 2001 From: JimmFly <447268514@qq.com> Date: Tue, 9 Apr 2024 04:28:30 +0000 Subject: [PATCH] fix(core): remove unexpected duplicate notification (#6477) close TOV-775 --- .../src/pages/workspace/collection/index.tsx | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/packages/frontend/core/src/pages/workspace/collection/index.tsx b/packages/frontend/core/src/pages/workspace/collection/index.tsx index 12e161cd00..05e3519a51 100644 --- a/packages/frontend/core/src/pages/workspace/collection/index.tsx +++ b/packages/frontend/core/src/pages/workspace/collection/index.tsx @@ -69,30 +69,29 @@ export const Component = function CollectionPage() { const params = useParams(); const workspace = useService(Workspace); const collection = collections.find(v => v.id === params.collectionId); + + const notifyCollectionDeleted = useCallback(() => { + navigate.jumpToSubPath(workspace.id, WorkspaceSubPath.ALL); + const collection = collectionService.collectionsTrash$.value.find( + v => v.collection.id === params.collectionId + ); + let text = 'Collection does not exist'; + if (collection) { + if (collection.userId) { + text = `${collection.collection.name} has been deleted by ${collection.userName}`; + } else { + text = `${collection.collection.name} has been deleted`; + } + } + return notify.error({ title: text }); + }, [collectionService, navigate, params.collectionId, workspace.id]); + useEffect(() => { if (!collection) { - navigate.jumpToSubPath(workspace.id, WorkspaceSubPath.ALL); - const collection = collectionService.collectionsTrash$.value.find( - v => v.collection.id === params.collectionId - ); - let text = 'Collection does not exist'; - if (collection) { - if (collection.userId) { - text = `${collection.collection.name} has been deleted by ${collection.userName}`; - } else { - text = `${collection.collection.name} has been deleted`; - } - } - notify.error({ title: text }); + notifyCollectionDeleted(); } - }, [ - collection, - collectionService.collectionsTrash$.value, - navigate, - params.collectionId, - workspace.docCollection, - workspace.id, - ]); + }, [collection, notifyCollectionDeleted]); + if (!collection) { return null; }