fix secondary channels

This commit is contained in:
marlon-erler
2024-07-09 18:44:13 +02:00
parent a1a9fd073c
commit c15ead428e
2 changed files with 9 additions and 8 deletions
+4 -4
View File
@@ -413,8 +413,9 @@
}; };
// handlers // handlers
onmessage = async (data) => { onmessage = async (data) => {
if (data.messageChannel && data.messageChannel != this.primaryChannel.value) if (!data.messageChannel) return;
return; const channels = data.messageChannel.split("/");
if (!this.primaryChannel.value in channels) return;
if (data.subscribed != void 0) this.handleSubscription(data.subscribed); if (data.subscribed != void 0) this.handleSubscription(data.subscribed);
if (!data.messageBody) return; if (!data.messageBody) return;
const { sender, body, channel, isoDate } = JSON.parse(data.messageBody); const { sender, body, channel, isoDate } = JSON.parse(data.messageBody);
@@ -436,7 +437,7 @@
if (this.cannotSendMessage.value == true) return; if (this.cannotSendMessage.value == true) return;
const secondaryChannelNames = [ const secondaryChannelNames = [
...this.secondaryChannels.value.values() ...this.secondaryChannels.value.values()
].map((channel) => channel); ];
const allChannelNames = [ const allChannelNames = [
this.primaryChannel.value, this.primaryChannel.value,
...secondaryChannelNames ...secondaryChannelNames
@@ -453,7 +454,6 @@
isoDate: (/* @__PURE__ */ new Date()).toISOString() isoDate: (/* @__PURE__ */ new Date()).toISOString()
}; };
const messageString = JSON.stringify(messageObject); const messageString = JSON.stringify(messageObject);
console.log(messageString);
UDN.sendMessage(joinedChannelName, messageString); UDN.sendMessage(joinedChannelName, messageString);
this.composingMessage.value = ""; this.composingMessage.value = "";
}; };
+5 -4
View File
@@ -98,12 +98,13 @@ export class Chat {
chats.remove(this); chats.remove(this);
chatIds.remove(this.id); chatIds.remove(this.id);
} };
// handlers // handlers
onmessage = async (data: Message): Promise<void> => { onmessage = async (data: Message): Promise<void> => {
if (data.messageChannel && data.messageChannel != this.primaryChannel.value) if (!data.messageChannel) return;
return; const channels = data.messageChannel.split("/");
if (!this.primaryChannel.value in channels) return;
if (data.subscribed != undefined) this.handleSubscription(data.subscribed); if (data.subscribed != undefined) this.handleSubscription(data.subscribed);
@@ -132,7 +133,7 @@ export class Chat {
// get channels // get channels
const secondaryChannelNames: string[] = [ const secondaryChannelNames: string[] = [
...this.secondaryChannels.value.values(), ...this.secondaryChannels.value.values(),
].map((channel) => channel); ];
const allChannelNames: string[] = [ const allChannelNames: string[] = [
this.primaryChannel.value, this.primaryChannel.value,
...secondaryChannelNames, ...secondaryChannelNames,