diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-10-29 14:01:12 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-10-29 14:58:16 +0300 |
commit | d5a2aed83c990285f83f5be8aced9ccb0570e78d (patch) | |
tree | 14799d5c61fa82d290facd8f0052167b6f86b7af /js/signaling.js | |
parent | cdd77bce21b6c5b28d579f68d991ac397ba4afca (diff) |
Unify room synchronization for users and guests
The main page gives a user access to more than one room, while the
public page only gives a guest access to a single room; guests can not
even query the list of rooms in the backend, so the app sets a room
collection only for users, but not guests. Before, the room model only
supported being part of a room collection, so there was no room model to
be used by the UI for guests. Now, the room model was extended to
support both being part of a room collection and being a standalone
model, and now the signaling can synchronize a single room model too
instead of only a room collection, so the UI can rely on the room model
set as active to be up to date for both users and guests.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'js/signaling.js')
-rw-r--r-- | js/signaling.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/js/signaling.js b/js/signaling.js index 8804e2b88..1bac8b641 100644 --- a/js/signaling.js +++ b/js/signaling.js @@ -75,6 +75,20 @@ return this.syncRooms(); }; + /** + * Sets a single room to be synced. + * + * If there is a RoomCollection set the synchronization will be performed on + * the RoomCollection instead and the given room will be ignored; setting a + * single room is intended to be used only on public pages. + * + * @param OCA.SpreedMe.Models.Room room the room to sync. + */ + SignalingBase.prototype.setRoom = function(room) { + this.room = room; + return this.syncRooms(); + }; + SignalingBase.prototype.syncRooms = function() { var defer = $.Deferred(); if (this.roomCollection && oc_current_user) { @@ -83,6 +97,12 @@ defer.resolve(data); } }); + } else if (this.room) { + this.room.fetch({ + success: function(data) { + defer.resolve(data); + } + }); } else { defer.resolve([]); } @@ -263,6 +283,11 @@ return SignalingBase.prototype.setRoomCollection.apply(this, arguments); }; + InternalSignaling.prototype.setRoom = function(/*room*/) { + this._pollForRoomChanges(); + return SignalingBase.prototype.setRoom.apply(this, arguments); + }; + InternalSignaling.prototype._pollForRoomChanges = function() { if (this.roomPoller) { window.clearInterval(this.roomPoller); |