Skip to content

Commit 8818661

Browse files
committed
channels.js: fix sendMessageTo for channels other than the app's channel
1 parent 5eb3092 commit 8818661

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

assets/js/channels.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Genie.findWebchannel = function(channel) {
1010
return this.AllWebChannels.find((app) => app.channel == channel);
1111
}
1212
Genie.findApp = function(channel) {
13-
return this.AllWebChannels.find((app) => app.channel == channel).parent;
13+
const webchannel = this.findWebchannel(channel);
14+
return (webchannel) ? webchannel.parent : this.AllWebChannels[0];
1415
}
1516
// Genie.WebChannels holds common handlers for all models
1617
Genie.WebChannels = {};
@@ -26,7 +27,8 @@ Genie.WebChannels.broadcastMessage = async (message, payload = {}) => {
2627
}
2728
};
2829
Genie.WebChannels.sendMessageTo = async (channel, message, payload = {}) => {
29-
const WebChannel = Genie.findApp(channel);
30+
var WebChannel = Genie.findApp(channel);
31+
(WebChannel) || (WebChannel = GENIEMODEL.WebChannel);
3032
WebChannel.sendMessageTo(channel, message, payload);
3133
}
3234

0 commit comments

Comments
 (0)