From d9f967b33c260038317f66b2c1da276bc59b1738 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Mon, 8 Sep 2025 13:13:55 +0200 Subject: [PATCH] Fix: Optimierung der Event-Abmeldung in BranchView.vue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Änderung: - Die Logik zur Abmeldung von WebSocket-Events wurde vereinfacht, indem die spezifischen Event-Namen direkt in der Methode `beforeUnmount` abgemeldet werden. Dies verbessert die Lesbarkeit und Wartbarkeit des Codes. Diese Anpassung sorgt für eine klarere Struktur und effizientere Handhabung der WebSocket-Events. --- frontend/src/views/falukant/BranchView.vue | 28 ++++++++-------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/frontend/src/views/falukant/BranchView.vue b/frontend/src/views/falukant/BranchView.vue index 78e0f26..2c3d3c0 100644 --- a/frontend/src/views/falukant/BranchView.vue +++ b/frontend/src/views/falukant/BranchView.vue @@ -94,24 +94,16 @@ export default { }, beforeUnmount() { - [ - "production_ready", - "stock_change", - "price_update", - "director_death", - "production_started", - "selled_items", - "falukantUpdateStatus", - "falukantBranchUpdate", - "knowledge_update" - ].forEach(eventName => { - if (this.socket) { - this.socket.off(eventName, this.handleEvent); - } - }); - - if (this.daemonSocket) { - this.daemonSocket.removeEventListener('message', this.handleDaemonMessage); + if (this.socket) { + this.socket.off("falukantBranchUpdate"); + this.socket.off("falukantUpdateStatus"); + this.socket.off("production_ready"); + this.socket.off("stock_change"); + this.socket.off("price_update"); + this.socket.off("director_death"); + this.socket.off("production_started"); + this.socket.off("selled_items"); + this.socket.off("knowledge_update"); } },