Bug 1074702 - Part 1 Implement join/refresh/leave with the Loop server on the standalone UI. r=nperriault

This commit is contained in:
Mark Banner
2014-11-07 16:28:13 +00:00
parent 1609f4bd46
commit dd55563a03
12 changed files with 557 additions and 31 deletions

View File

@@ -273,6 +273,12 @@ loop.shared.actions = (function() {
sessionToken: String,
sessionId: String,
expires: Number
}),
/**
* Used to indicate the user wishes to leave the room.
*/
LeaveRoom: Action.define("leaveRoom", {
})
};
})();

View File

@@ -52,10 +52,12 @@ loop.store.ActiveRoomStore = (function() {
this._dispatcher.register(this, [
"roomFailure",
"setupWindowData",
"fetchServerData",
"updateRoomInfo",
"joinRoom",
"joinedRoom",
"windowUnload"
"windowUnload",
"leaveRoom"
]);
/**
@@ -151,6 +153,26 @@ loop.store.ActiveRoomStore = (function() {
}.bind(this));
},
/**
* Execute fetchServerData event action from the dispatcher. Although
* this is to fetch the server data - for rooms on the standalone client,
* we don't actually need to get any data. Therefore we just save the
* data that is given to us for when the user chooses to join the room.
*
* @param {sharedActions.FetchServerData} actionData
*/
fetchServerData: function(actionData) {
if (actionData.windowType !== "room") {
// Nothing for us to do here, leave it to other stores.
return;
}
this.setStoreState({
roomToken: actionData.token,
roomState: ROOM_STATES.READY
});
},
/**
* Handles the updateRoomInfo action. Updates the room data and
* sets the state to `READY`.
@@ -213,6 +235,13 @@ loop.store.ActiveRoomStore = (function() {
this._leaveRoom();
},
/**
* Handles a room being left.
*/
leaveRoom: function() {
this._leaveRoom();
},
/**
* Handles setting of the refresh timeout callback.
*