fix recording update channel and routes

This commit is contained in:
Zachary Chai
2017-01-31 11:42:47 -05:00
parent c70ad42d8b
commit 9667e3757b
4 changed files with 33 additions and 15 deletions

View File

@ -62,13 +62,13 @@
};
$(document).on("turbolinks:load", function() {
// disable meeting updates if enabled from a previous page
if (App.meeting_update) {
disableMeetingUpdates();
}
if ($("body[data-controller=landing]").get(0)) {
if ($("body[data-action=rooms]").get(0)) {
// disable meeting updates if enabled from a previous page
if (App.meeting_update) {
disableMeetingUpdates();
}
if ($(".page-wrapper.rooms").data('main-room') === false) {
if (!$(".page-wrapper.rooms").data('main-room')) {
enableMeetingUpdates();
}
}

View File

@ -16,10 +16,11 @@
(function() {
var initRooms = function() {
App.messages = App.cable.subscriptions.create({
var enableRecordingUpdates = function() {
App.recording_update = App.cable.subscriptions.create({
channel: 'RecordingUpdatesChannel',
encrypted_id: $(".page-wrapper").data('id')
admin_id: $(".page-wrapper.rooms").data('admin-id'),
meeting_id: $(".page-wrapper.rooms").data('id')
},
{
received: function(data) {
@ -57,10 +58,19 @@
});
};
var disableRecordingUpdates = function() {
App.recording_update.unsubscribe();
delete App.recording_update
};
$(document).on("turbolinks:load", function() {
// disable recording updates if enabled from a previous page
if (App.recording_update) {
disableRecordingUpdates();
}
if ($("body[data-controller=landing]").get(0)) {
if ($("body[data-action=rooms]").get(0)) {
initRooms();
enableRecordingUpdates();
}
}
});