Skip to content

Commit

Permalink
channels.js: fix sendMessageTo for channels other than the app's channel
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Jan 28, 2025
1 parent 5eb3092 commit 8818661
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions assets/js/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Genie.findWebchannel = function(channel) {
return this.AllWebChannels.find((app) => app.channel == channel);
}
Genie.findApp = function(channel) {
return this.AllWebChannels.find((app) => app.channel == channel).parent;
const webchannel = this.findWebchannel(channel);
return (webchannel) ? webchannel.parent : this.AllWebChannels[0];
}
// Genie.WebChannels holds common handlers for all models
Genie.WebChannels = {};
Expand All @@ -26,7 +27,8 @@ Genie.WebChannels.broadcastMessage = async (message, payload = {}) => {
}
};
Genie.WebChannels.sendMessageTo = async (channel, message, payload = {}) => {
const WebChannel = Genie.findApp(channel);
var WebChannel = Genie.findApp(channel);
(WebChannel) || (WebChannel = GENIEMODEL.WebChannel);
WebChannel.sendMessageTo(channel, message, payload);
}

Expand Down

0 comments on commit 8818661

Please sign in to comment.