From f58c91fb3fd9c200d1cf7576884a37c7a0f2686c Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 1 Mar 2023 19:05:56 +0800 Subject: [PATCH] fix: filter notification with id --- .../components/TestApiButton/TestGrid.tsx | 3 ++- .../stores/effects/database/cell/cell_cache.ts | 1 - .../services/backend/notifications/observer.ts | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/TestApiButton/TestGrid.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/TestApiButton/TestGrid.tsx index fb5584935b..6882d19549 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/TestApiButton/TestGrid.tsx +++ b/frontend/appflowy_tauri/src/appflowy_app/components/TestApiButton/TestGrid.tsx @@ -26,7 +26,7 @@ export const TestCreateGrid = () => { }, onRowsChanged: async (rows) => { if (rows.length !== 3) { - throw Error('Expected number of rows is 3, but receive ' + rows.length); + throw Error('Expected number of rows is 3, but receive ' + rows.length + view.id); } }, onFieldsChanged: (fields) => { @@ -36,6 +36,7 @@ export const TestCreateGrid = () => { }, }); await databaseController.open().then((result) => result.unwrap()); + await databaseController.dispose(); } return TestButton('Test create build-in grid', createBuildInGrid); diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/cell_cache.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/cell_cache.ts index 979a06ee0b..27099145c3 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/cell_cache.ts +++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/cell_cache.ts @@ -15,7 +15,6 @@ export class CellCache { remove = (key: CellCacheKey) => { const cellDataByRowId = this.cellDataByFieldId.get(key.fieldId); if (cellDataByRowId !== undefined) { - console.log('cellDataByRowId', cellDataByRowId); cellDataByRowId.delete(key.rowId); } }; diff --git a/frontend/appflowy_tauri/src/services/backend/notifications/observer.ts b/frontend/appflowy_tauri/src/services/backend/notifications/observer.ts index 282886243c..c6f951288e 100644 --- a/frontend/appflowy_tauri/src/services/backend/notifications/observer.ts +++ b/frontend/appflowy_tauri/src/services/backend/notifications/observer.ts @@ -1,6 +1,6 @@ -import { listen, UnlistenFn } from '@tauri-apps/api/event'; -import { SubscribeObject } from '../models/flowy-notification'; -import { NotificationParser } from './parser'; +import { listen, UnlistenFn } from "@tauri-apps/api/event"; +import { SubscribeObject } from "../models/flowy-notification"; +import { NotificationParser } from "./parser"; export abstract class AFNotificationObserver { parser?: NotificationParser | null; @@ -11,9 +11,15 @@ export abstract class AFNotificationObserver { } async start() { - this._listener = await listen('af-notification', (notification) => { - const object = SubscribeObject.fromObject(notification.payload as {}); - this.parser?.parse(object); + this._listener = await listen("af-notification", (notification) => { + const object: SubscribeObject = SubscribeObject.fromObject(notification.payload as {}); + if (this.parser?.id !== undefined) { + if (object.id === this.parser.id) { + this.parser?.parse(object); + } + } else { + this.parser?.parse(object); + } }); }