|
@@ -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<T> {
|
|
|
parser?: NotificationParser<T> | null;
|
|
@@ -11,9 +11,15 @@ export abstract class AFNotificationObserver<T> {
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|