forked from External/greenlight
		
	add user waiting notifications back to main room
This commit is contained in:
		@@ -24,10 +24,14 @@
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  var enableMeetingUpdates = function() {
 | 
			
		||||
    var meetingId = ''
 | 
			
		||||
    if (!$(".page-wrapper.rooms").data('main-room')) {
 | 
			
		||||
      meetingId = $(".page-wrapper.rooms").data('id');
 | 
			
		||||
    }
 | 
			
		||||
    App.meeting_update = App.cable.subscriptions.create({
 | 
			
		||||
      channel: 'MeetingUpdatesChannel',
 | 
			
		||||
      admin_id: $(".page-wrapper.rooms").data('admin-id'),
 | 
			
		||||
      meeting_id: $(".page-wrapper.rooms").data('id')
 | 
			
		||||
      meeting_id: meetingId
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      received: function(data) {
 | 
			
		||||
@@ -46,7 +50,7 @@
 | 
			
		||||
          showAlert(I18n.meeting_ended, 4000);
 | 
			
		||||
        } else if (data.action === 'user_waiting') {
 | 
			
		||||
          // show a browser notification only to the owner
 | 
			
		||||
          if (GreenLight.user.roomOwner) {
 | 
			
		||||
          if (isRoomOwner()) {
 | 
			
		||||
            showNotification(I18n.user_waiting_title, {
 | 
			
		||||
              body: I18n.user_waiting_body.replace(/%{user}/, data.user)
 | 
			
		||||
            });
 | 
			
		||||
@@ -68,9 +72,7 @@
 | 
			
		||||
    }
 | 
			
		||||
    if ($("body[data-controller=landing]").get(0)) {
 | 
			
		||||
      if ($("body[data-action=rooms]").get(0)) {
 | 
			
		||||
        if (!$(".page-wrapper.rooms").data('main-room')) {
 | 
			
		||||
          enableMeetingUpdates();
 | 
			
		||||
        }
 | 
			
		||||
        enableMeetingUpdates();
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
 
 | 
			
		||||
@@ -68,10 +68,14 @@ var showNotification = function(title, options) {
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
var isRoomOwner = function() {
 | 
			
		||||
  return $('body').data('current-user') === $('.page-wrapper.rooms').data('admin-id')
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// For now there are notifications only for users signed in and when they
 | 
			
		||||
// are in their room's page
 | 
			
		||||
$(document).on("turbolinks:load", function() {
 | 
			
		||||
  if (GreenLight.user.roomOwner) {
 | 
			
		||||
  if (isRoomOwner()) {
 | 
			
		||||
    Notification.requestPermission();
 | 
			
		||||
  }
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user