Skip to content

Commit c45b8c2

Browse files
committed
fix: unsubscribe from websocket before subsribing, when we call adminforth.menu.refreshMenuBadges()
https://web.tracklify.com/project/2b7ZVgE5/AdminForth/1293/VZgUq1zq/find-out-why-do-we-unsubscribe
1 parent d80b46a commit c45b8c2

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

adminforth/spa/src/stores/core.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const useCoreStore = defineStore('core', () => {
9292

9393
// console.log('🔔 subscribeToMenuBadges', mi.badge, JSON.stringify(mi));
9494
if (mi.badge !== undefined) {
95+
websocket.unsubscribe(`/opentopic/update-menu-badge/${mi.itemId}`);
9596
websocket.subscribe(`/opentopic/update-menu-badge/${mi.itemId}`, ({ badge }) => {
9697
mi.badge = badge;
9798
});
@@ -121,8 +122,6 @@ export const useCoreStore = defineStore('core', () => {
121122
item.badge = badge;
122123
}
123124
});
124-
// TODO: This thing was created for something. Find out why
125-
// websocket.unsubscribeAll();
126125
subscribeToMenuBadges();
127126

128127
}

0 commit comments

Comments
 (0)