From c15ead428e424a26b7a528005e67cf90b43cf9c6 Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Tue, 9 Jul 2024 18:44:13 +0200 Subject: [PATCH] fix secondary channels --- dist/index.js | 8 ++++---- src/Model/chatModel.ts | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/dist/index.js b/dist/index.js index 889cc0e9..245748fe 100644 --- a/dist/index.js +++ b/dist/index.js @@ -413,8 +413,9 @@ }; // handlers onmessage = async (data) => { - if (data.messageChannel && data.messageChannel != this.primaryChannel.value) - return; + if (!data.messageChannel) return; + const channels = data.messageChannel.split("/"); + if (!this.primaryChannel.value in channels) return; if (data.subscribed != void 0) this.handleSubscription(data.subscribed); if (!data.messageBody) return; const { sender, body, channel, isoDate } = JSON.parse(data.messageBody); @@ -436,7 +437,7 @@ if (this.cannotSendMessage.value == true) return; const secondaryChannelNames = [ ...this.secondaryChannels.value.values() - ].map((channel) => channel); + ]; const allChannelNames = [ this.primaryChannel.value, ...secondaryChannelNames @@ -453,7 +454,6 @@ isoDate: (/* @__PURE__ */ new Date()).toISOString() }; const messageString = JSON.stringify(messageObject); - console.log(messageString); UDN.sendMessage(joinedChannelName, messageString); this.composingMessage.value = ""; }; diff --git a/src/Model/chatModel.ts b/src/Model/chatModel.ts index 89890ff5..780dc2b8 100644 --- a/src/Model/chatModel.ts +++ b/src/Model/chatModel.ts @@ -98,12 +98,13 @@ export class Chat { chats.remove(this); chatIds.remove(this.id); - } + }; // handlers onmessage = async (data: Message): Promise => { - if (data.messageChannel && data.messageChannel != this.primaryChannel.value) - return; + if (!data.messageChannel) return; + const channels = data.messageChannel.split("/"); + if (!this.primaryChannel.value in channels) return; if (data.subscribed != undefined) this.handleSubscription(data.subscribed); @@ -132,7 +133,7 @@ export class Chat { // get channels const secondaryChannelNames: string[] = [ ...this.secondaryChannels.value.values(), - ].map((channel) => channel); + ]; const allChannelNames: string[] = [ this.primaryChannel.value, ...secondaryChannelNames,