From 4ea99bc51b91421cf59a44b5a3d05dfa2dcea8a3 Mon Sep 17 00:00:00 2001 From: Aylur Date: Tue, 12 Sep 2023 19:11:42 +0200 Subject: [PATCH] fix: dont cache notification actions --- src/service/notifications.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/service/notifications.ts b/src/service/notifications.ts index fe30192..898e859 100644 --- a/src/service/notifications.ts +++ b/src/service/notifications.ts @@ -202,12 +202,12 @@ class NotificationsService extends Service { try { const file = await readFileAsync(CACHE_FILE); const notifications = JSON.parse(file as string) as Notification[]; - notifications.forEach(n => { + for (const n of notifications) { if (n.id > this._idCount) this._idCount = n.id + 1; this._notifications.set(n.id, n); - }); + } this.emit('changed'); } catch (_) { @@ -247,11 +247,8 @@ class NotificationsService extends Service { } private _cache() { - const notifications = []; - for (const [, notification] of this._notifications) { - const n = { ...notification, action: [], popup: false }; - notifications.push(n); - } + const notifications = Array.from(this._notifications.values()) + .map(n => ({ ...n, actions: [], popup: false })); ensureDirectory(NOTIFICATIONS_CACHE_PATH); const json = JSON.stringify(notifications, null, 2);