소스 검색

fix: Events unsubscribing when used more than once

Owen Diffey 1 년 전
부모
커밋
b18a49fb7f
1개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 6 3
      frontend/src/stores/websocket.ts

+ 6 - 3
frontend/src/stores/websocket.ts

@@ -51,15 +51,18 @@ export const useWebsocketStore = defineStore("websocket", () => {
 	};
 
 	const unsubscribe = async (channel: string, uuid: string) => {
-		if (!socketChannels.includes(channel))
-			await runJob("api.unsubscribe", { channel });
-
 		if (
 			!subscriptions.value[channel] ||
 			!subscriptions.value[channel][uuid]
 		)
 			return;
 
+		if (
+			!socketChannels.includes(channel) &&
+			Object.keys(subscriptions.value[channel]).length <= 1
+		)
+			await runJob("api.unsubscribe", { channel });
+
 		delete subscriptions.value[channel][uuid];
 
 		if (Object.keys(subscriptions.value[channel]).length === 0)