Browse Source

Make ParticipantCollection to automatically fetch when its room changes

The ParticipantCollection provides the list of participants (including
guests) in a room. The Room model is synced through signaling and
provides some information about the registered users and the guests in a
room, so the ParticipantCollection can listen to changes in those
properties to automatically fetch its items again when needed.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
pull/439/head
Daniel Calviño Sánchez 8 years ago
parent
commit
c516ddf513
  1. 12
      js/models/participantcollection.js
  2. 1
      js/views/roomlistview.js

12
js/models/participantcollection.js

@ -35,8 +35,20 @@
* @returns {Array}
*/
setRoom: function(room) {
this.stopListening(this.room, 'change:participants');
this.stopListening(this.room, 'change:guestList');
this.room = room;
this.url = OC.linkToOCS('apps/spreed/api/v1/room', 2) + this.room.get('token') + '/participants';
this.fetch();
this.listenTo(this.room, 'change:participants', function() {
this.fetch();
});
this.listenTo(this.room, 'change:guestList', function() {
this.fetch();
});
},
/**

1
js/views/roomlistview.js

@ -185,7 +185,6 @@
$sidebar.find('.room-name').text(this.model.get('displayName'));
OCA.SpreedMe.app._participants.setRoom(this.model);
OCA.SpreedMe.app._participants.fetch();
if (!$content.hasClass('with-app-sidebar')) {
$content.addClass('with-app-sidebar');

Loading…
Cancel
Save