Skip to content

Commit

Permalink
Hack up some JS to make device page work with new DeviceChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmorrison committed Mar 6, 2023
1 parent 396a397 commit fabd622
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/javascript/channels/colors_channel.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import consumer from "channels/consumer"

let ids = document.location.pathname.match(/^\/([^\/\?]*)/)[1].split(",");
ids.forEach( function(id) {
let ids, channel;

if (document.location.pathname.match(/^\/devices\//)) {
ids = document.location.pathname.match(/^\/devices\/([^\/\?]*)/)[1].split(",");
channel = "DeviceChannel";
} else {
ids = document.location.pathname.match(/^\/([^\/\?]*)/)[1].split(",");
channel = "ColorsChannel";
}

ids.forEach(function (id) {
if (id === "") {
id = "*";
}

consumer.subscriptions.create({channel: "ColorsChannel", id: id}, {
consumer.subscriptions.create({ channel: channel, id: id }, {
connected() {
// Called when the subscription is ready for use on the server
},
Expand Down

0 comments on commit fabd622

Please sign in to comment.