Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(core): remove unexpected duplicate notification (#6477)

JimmFly142896c41aad
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;
}