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() {
[ if (this.socket) {
"production_ready", this.socket.off("falukantBranchUpdate");
"stock_change", this.socket.off("falukantUpdateStatus");
"price_update", this.socket.off("production_ready");
"director_death", this.socket.off("stock_change");
"production_started", this.socket.off("price_update");
"selled_items", this.socket.off("director_death");
"falukantUpdateStatus", this.socket.off("production_started");
"falukantBranchUpdate", this.socket.off("selled_items");
"knowledge_update" this.socket.off("knowledge_update");
].forEach(eventName => {
if (this.socket) {
this.socket.off(eventName, this.handleEvent);
}
});
if (this.daemonSocket) {
this.daemonSocket.removeEventListener('message', this.handleDaemonMessage);
} }
}, },