From 673fc013b387d80c7d9efb41dc4e1c7b008385ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Wed, 10 Apr 2019 10:49:36 +0200 Subject: Get room from model instead of from app object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even if the same ParticipantListView can be reused with different rooms each of its items are shown only for a participant in a specific room (as the participant models are created again whenever a new room is set in the ParticipantCollection). Therefore there is no need to get the active room from the app object; it can be got directly from its model when the item view is created. Signed-off-by: Daniel Calviño Sánchez --- js/views/participantlistview.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/js/views/participantlistview.js b/js/views/participantlistview.js index 353ced662..16bfc9b4d 100644 --- a/js/views/participantlistview.js +++ b/js/views/participantlistview.js @@ -99,6 +99,8 @@ }, }, initialize: function() { + this.room = this.model.collection.room; + 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 +115,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 +223,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 +269,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 +311,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 }, -- cgit v1.2.3 From 3a8503ec2f3e5f4ed141b254a5a4fc85d8d400a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Wed, 10 Apr 2019 11:22:47 +0200 Subject: Fix participant actions not updated on current participant type changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the type of the current participant changes the available actions on the other participants change too (for example, promoting can be now available or no longer available), so the items in the ParticipantListView should be rendered again to reflect the new actions. Signed-off-by: Daniel Calviño Sánchez --- js/views/participantlistview.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/views/participantlistview.js b/js/views/participantlistview.js index 16bfc9b4d..c9915fbef 100644 --- a/js/views/participantlistview.js +++ b/js/views/participantlistview.js @@ -101,6 +101,13 @@ 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)) { -- cgit v1.2.3