diff options
-rw-r--r-- | js/views/participantlistview.js | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/js/views/participantlistview.js b/js/views/participantlistview.js index 353ced662..c9915fbef 100644 --- a/js/views/participantlistview.js +++ b/js/views/participantlistview.js @@ -99,6 +99,15 @@ }, }, initialize: function() { + this.room = this.model.collection.room; + + // When the type of the current participant changes the + // available actions on the participant shown by this item view + // change too, so the view should be rendered again. + this.listenTo(this.room, 'change:participantType', function() { + this.render(); + }); + this.listenTo(uiChannel, 'document:click', function(event) { var target = $(event.target); if (!target.closest('.popovermenu').is(this.ui.menu) && !target.is(this.ui.menuButton)) { @@ -113,11 +122,11 @@ isModerator = false; if (OC.getCurrentUser().uid) { isSelf = this.model.get('userId') === OC.getCurrentUser().uid; - isModerator = OCA.SpreedMe.app.activeRoom.get('participantType') === OCA.SpreedMe.app.OWNER || - OCA.SpreedMe.app.activeRoom.get('participantType') === OCA.SpreedMe.app.MODERATOR; + isModerator = this.room.get('participantType') === OCA.SpreedMe.app.OWNER || + this.room.get('participantType') === OCA.SpreedMe.app.MODERATOR; } else { - isSelf = this.model.get('sessionId') === OCA.SpreedMe.app.activeRoom.get('sessionId'); - isModerator = OCA.SpreedMe.app.activeRoom.get('participantType') === OCA.SpreedMe.app.GUEST_MODERATOR; + isSelf = this.model.get('sessionId') === this.room.get('sessionId'); + isModerator = this.room.get('participantType') === OCA.SpreedMe.app.GUEST_MODERATOR; } var canModerate = this.model.get('participantType') !== OCA.SpreedMe.app.OWNER && // can not moderate owners @@ -221,7 +230,7 @@ $.ajax({ type: 'POST', - url: OC.linkToOCS('apps/spreed/api/v1/room', 2) + OCA.SpreedMe.app.activeRoom.get('token') + '/moderators', + url: OC.linkToOCS('apps/spreed/api/v1/room', 2) + this.room.get('token') + '/moderators', data: data, success: function() { if (self.model.get('userId')) { @@ -267,7 +276,7 @@ $.ajax({ type: 'DELETE', - url: OC.linkToOCS('apps/spreed/api/v1/room', 2) + OCA.SpreedMe.app.activeRoom.get('token') + '/moderators', + url: OC.linkToOCS('apps/spreed/api/v1/room', 2) + this.room.get('token') + '/moderators', data:data, success: function() { if (self.model.get('userId')) { @@ -309,7 +318,7 @@ $.ajax({ type: 'DELETE', - url: OC.linkToOCS('apps/spreed/api/v1/room', 2) + OCA.SpreedMe.app.activeRoom.get('token') + endpoint, + url: OC.linkToOCS('apps/spreed/api/v1/room', 2) + this.room.get('token') + endpoint, data: { participant: participantId }, |