Bug 1114563 - Show the room name before the user enters the room. r=mikedeboer

This commit is contained in:
Mark Banner 2015-03-25 17:08:19 +00:00
parent 199bbc37fa
commit 205504b3d0
2 changed files with 48 additions and 54 deletions

View File

@ -182,10 +182,10 @@ loop.store.ActiveRoomStore = (function() {
},
/**
* 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.
* Execute fetchServerData event action from the dispatcher. For rooms
* we need to get the room context information from the server. We don't
* need other data until the user decides to join the room.
* This action is only used for the standalone UI.
*
* @param {sharedActions.FetchServerData} actionData
*/
@ -206,6 +206,18 @@ loop.store.ActiveRoomStore = (function() {
this._handleRoomUpdate.bind(this));
this._mozLoop.rooms.on("delete:" + actionData.roomToken,
this._handleRoomDelete.bind(this));
this._mozLoop.rooms.get(this._storeState.roomToken,
function(err, result) {
if (err) {
// XXX Bug 1110937 will want to handle the error results here
// e.g. room expired/invalid.
console.error("Failed to get room data:", err);
return;
}
this.dispatcher.dispatch(new sharedActions.UpdateRoomInfo(result));
}.bind(this));
},
/**
@ -341,21 +353,6 @@ loop.store.ActiveRoomStore = (function() {
this._mozLoop.addConversationContext(this._storeState.windowId,
actionData.sessionId, "");
// If we haven't got a room name yet, go and get one. We typically
// need to do this in the case of the standalone window.
// XXX When bug 1103331 lands this can be moved to earlier.
if (!this._storeState.roomName) {
this._mozLoop.rooms.get(this._storeState.roomToken,
function(err, result) {
if (err) {
console.error("Failed to get room data:", err);
return;
}
this.dispatcher.dispatch(new sharedActions.UpdateRoomInfo(result));
}.bind(this));
}
},
/**

View File

@ -320,23 +320,48 @@ describe("loop.store.ActiveRoomStore", function () {
});
describe("#fetchServerData", function() {
it("should save the token", function() {
store.fetchServerData(new sharedActions.FetchServerData({
var fetchServerAction;
beforeEach(function() {
fetchServerAction = new sharedActions.FetchServerData({
windowType: "room",
token: "fakeToken"
}));
});
});
it("should save the token", function() {
store.fetchServerData(fetchServerAction);
expect(store.getStoreState().roomToken).eql("fakeToken");
});
it("should set the state to `READY`", function() {
store.fetchServerData(new sharedActions.FetchServerData({
windowType: "room",
token: "fakeToken"
}));
store.fetchServerData(fetchServerAction);
expect(store.getStoreState().roomState).eql(ROOM_STATES.READY);
});
it("should call mozLoop.rooms.get to get the room data", function() {
store.fetchServerData(fetchServerAction);
sinon.assert.calledOnce(fakeMozLoop.rooms.get);
});
it("should dispatch UpdateRoomInfo if mozLoop.rooms.get is successful", function() {
var roomDetails = {
roomName: "fakeName",
roomUrl: "http://invalid",
roomOwner: "gavin"
};
fakeMozLoop.rooms.get.callsArgWith(1, null, roomDetails);
store.fetchServerData(fetchServerAction);
sinon.assert.calledOnce(dispatcher.dispatch);
sinon.assert.calledWithExactly(dispatcher.dispatch,
new sharedActions.UpdateRoomInfo(roomDetails));
});
});
describe("#feedbackComplete", function() {
@ -578,34 +603,6 @@ describe("loop.store.ActiveRoomStore", function () {
"42", "15263748", "");
});
it("should call mozLoop.rooms.get to get the room data if the roomName" +
"is not known", function() {
store.setStoreState({roomName: undefined});
store.joinedRoom(new sharedActions.JoinedRoom(fakeJoinedData));
sinon.assert.calledOnce(fakeMozLoop.rooms.get);
});
it("should dispatch UpdateRoomInfo if mozLoop.rooms.get is successful",
function() {
var roomDetails = {
roomName: "fakeName",
roomUrl: "http://invalid",
roomOwner: "gavin"
};
fakeMozLoop.rooms.get.callsArgWith(1, null, roomDetails);
store.setStoreState({roomName: undefined});
store.joinedRoom(new sharedActions.JoinedRoom(fakeJoinedData));
sinon.assert.calledOnce(dispatcher.dispatch);
sinon.assert.calledWithExactly(dispatcher.dispatch,
new sharedActions.UpdateRoomInfo(roomDetails));
});
it("should call mozLoop.rooms.refreshMembership before the expiresTime",
function() {
store.joinedRoom(new sharedActions.JoinedRoom(fakeJoinedData));