Fix: Optimierung der Event-Abmeldung in BranchView.vue

Ä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.
This commit is contained in:
Torsten Schulz (local)
2025-09-08 13:13:55 +02:00
parent 917b04fb5e
commit d9f967b33c

View File

@@ -94,24 +94,16 @@ export default {
}, },
beforeUnmount() { beforeUnmount() {
[
"production_ready",
"stock_change",
"price_update",
"director_death",
"production_started",
"selled_items",
"falukantUpdateStatus",
"falukantBranchUpdate",
"knowledge_update"
].forEach(eventName => {
if (this.socket) { if (this.socket) {
this.socket.off(eventName, this.handleEvent); this.socket.off("falukantBranchUpdate");
} this.socket.off("falukantUpdateStatus");
}); this.socket.off("production_ready");
this.socket.off("stock_change");
if (this.daemonSocket) { this.socket.off("price_update");
this.daemonSocket.removeEventListener('message', this.handleDaemonMessage); this.socket.off("director_death");
this.socket.off("production_started");
this.socket.off("selled_items");
this.socket.off("knowledge_update");
} }
}, },