mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +02:00
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 <maplenagisa@gmail.com>
This commit is contained in:
@@ -75,7 +75,7 @@ export const useNotificationStore = defineStore('Notification', () => {
|
|||||||
const unseenNotifications = ref([]);
|
const unseenNotifications = ref([]);
|
||||||
const isNotificationsLoading = ref(false);
|
const isNotificationsLoading = ref(false);
|
||||||
|
|
||||||
const notyMap = ref([]);
|
let notyMap = {};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => watchState.isLoggedIn,
|
() => watchState.isLoggedIn,
|
||||||
@@ -607,14 +607,19 @@ export const useNotificationStore = defineStore('Notification', () => {
|
|||||||
// don't play noty twice
|
// don't play noty twice
|
||||||
const notyId = `${noty.type},${displayName}`;
|
const notyId = `${noty.type},${displayName}`;
|
||||||
if (
|
if (
|
||||||
notyMap.value[notyId] &&
|
notyMap[notyId] &&
|
||||||
notyMap.value[notyId] >= noty.created_at
|
notyMap[notyId] >= noty.created_at
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
notyMap.value[notyId] = noty.created_at;
|
notyMap[notyId] = noty.created_at;
|
||||||
}
|
}
|
||||||
const bias = new Date(Date.now() - 60000).toJSON();
|
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) {
|
if (noty.created_at < bias) {
|
||||||
// don't play noty if it's over 1min old
|
// don't play noty if it's over 1min old
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user