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>
This commit is contained in:
Daniel Calviño Sánchez 2017-10-13 06:41:44 +02:00
Родитель e26d1f17b9
Коммит c516ddf513
2 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@ -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();
});
},
/**

Просмотреть файл

@ -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');