From b3b655d8ac512928ad9acbeb0c73df01d972fbc6 Mon Sep 17 00:00:00 2001 From: SymphonyVR <47229536+SymphonyVR@users.noreply.github.com> Date: Sat, 24 Jan 2026 12:39:25 -0400 Subject: [PATCH] fix(memory leak): implement self-destruct timeout for notyMap (#1594) * fix(notification): implement self-destruct timeout for notyMap to prevent memory leak * fix --------- Co-authored-by: Map1en --- src/stores/notification.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/stores/notification.js b/src/stores/notification.js index e76e52ef..62e0c0d9 100644 --- a/src/stores/notification.js +++ b/src/stores/notification.js @@ -75,7 +75,7 @@ export const useNotificationStore = defineStore('Notification', () => { const unseenNotifications = ref([]); const isNotificationsLoading = ref(false); - const notyMap = ref([]); + let notyMap = {}; watch( () => watchState.isLoggedIn, @@ -607,14 +607,19 @@ export const useNotificationStore = defineStore('Notification', () => { // don't play noty twice const notyId = `${noty.type},${displayName}`; if ( - notyMap.value[notyId] && - notyMap.value[notyId] >= noty.created_at + notyMap[notyId] && + notyMap[notyId] >= noty.created_at ) { return; } - notyMap.value[notyId] = noty.created_at; + notyMap[notyId] = noty.created_at; } const bias = new Date(Date.now() - 60000).toJSON(); + for (const [notyId, createdAt] of Object.entries(notyMap)) { + if (createdAt < bias) { + delete notyMap[notyId]; + } + } if (noty.created_at < bias) { // don't play noty if it's over 1min old return;