Skip to content

Commit 585021e

Browse files
committed
prevent notification processing while muted instead of disconnecting SSE
1 parent b3b73e0 commit 585021e

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

client/src/stores/inAppNotification.store.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ export const useInAppNotificationStore = defineStore('inAppNotification', () =>
7272
const toggleMute = () => {
7373
isMuted.value = !isMuted.value;
7474
localStorage.setItem('notification_muted', String(isMuted.value));
75-
76-
if (isMuted.value) {
77-
disconnectSSE();
78-
} else {
79-
setupSSE();
80-
}
8175
};
8276

8377
const setupSSE = () => {
@@ -89,9 +83,6 @@ export const useInAppNotificationStore = defineStore('inAppNotification', () =>
8983
// Fetch history immediately, regardless of mute state
9084
fetchNotifications();
9185

92-
// If muted, do not establish SSE connection
93-
if (isMuted.value) return;
94-
9586
if (eventSource) {
9687
eventSource.close();
9788
}
@@ -131,8 +122,11 @@ export const useInAppNotificationStore = defineStore('inAppNotification', () =>
131122
// Support both old formatted direct notifications and new {type: 'NOTIFICATION', payload: ...}
132123
const payload = eventData.type === 'NOTIFICATION' ? eventData.payload : eventData;
133124

134-
// If it looks like a notification
125+
// Seleziona se sembra una notifica
135126
if (payload._id && payload.title) {
127+
// Skip adding the notification if we are muted
128+
if (isMuted.value) return;
129+
136130
const newNotification: InAppNotification = {
137131
id: payload._id,
138132
title: payload.title,

0 commit comments

Comments
 (0)