From b00c7927b5308bbb390be41cc7809645003ad42b Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Tue, 9 Jul 2024 02:32:04 +0200 Subject: [PATCH] cleanup --- subscriptionHandler.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/subscriptionHandler.ts b/subscriptionHandler.ts index f108ec7..102250b 100644 --- a/subscriptionHandler.ts +++ b/subscriptionHandler.ts @@ -68,15 +68,20 @@ export class Mailbox implements Subscriber { set ws(ws: WS) { this._ws = ws; + this.update(); + } + + update() { + if (!this._ws) return; this.dateLastUsed = new Date(); this.confirmConnection(); this.sendUnreadMessages(); - const channels = subscriptionMap.getChannelList(ws); + const channels = subscriptionMap.getChannelList(this._ws); channels?.forEach((channel) => this.subscribe(channel)); - subscriptionMap.deleteSubscriber(ws); + subscriptionMap.deleteSubscriber(this._ws); } // subscribing