Follow-up to bug 1079225 - Fix formatting of the waiting for media message in Loop rooms, and ensure feedback can be given for multiple conversations in a row. r=abr

This commit is contained in:
Mark Banner 2014-11-26 21:09:09 +00:00
parent 6ea9853ef0
commit 73b54b9cdb
11 changed files with 74 additions and 29 deletions

View File

@ -331,9 +331,10 @@ loop.shared.actions = (function() {
}),
/**
* Resets current room.
* Used to indicate that the feedback cycle is completed and the countdown
* finished.
*/
ResetRoom: Action.define("resetRoom", {
FeedbackComplete: Action.define("feedbackComplete", {
}),
/**

View File

@ -140,7 +140,7 @@ loop.store.ActiveRoomStore = (function() {
"remotePeerConnected",
"windowUnload",
"leaveRoom",
"resetRoom"
"feedbackComplete"
]);
},
@ -453,9 +453,11 @@ loop.store.ActiveRoomStore = (function() {
},
/**
* Resets current room.
* When feedback is complete, we reset the room to the initial state.
*/
resetRoom: function() {
feedbackComplete: function() {
// Note, that we want some values, such as the windowId, so we don't
// do a full reset here.
this.setStoreState(this.getInitialStoreState());
}
});

View File

@ -37,7 +37,8 @@ loop.store.FeedbackStore = (function() {
actions: [
"requireFeedbackDetails",
"sendFeedback",
"sendFeedbackError"
"sendFeedbackError",
"feedbackComplete"
],
initialize: function(options) {
@ -91,6 +92,14 @@ loop.store.FeedbackStore = (function() {
feedbackState: FEEDBACK_STATES.FAILED,
error: actionData.error
});
},
/**
* Resets the store to its initial state as feedback has been completed,
* i.e. ready for the next round of feedback.
*/
feedbackComplete: function() {
this.resetStoreState();
}
});

View File

@ -54,6 +54,17 @@ loop.store.createStore = (function() {
this.trigger("change:" + key);
}
this.trigger("change");
},
/**
* Resets the store state to the initially defined state.
*/
resetStoreState: function() {
if (typeof this.getInitialStoreState === "function") {
this._storeState = this.getInitialStoreState();
} else {
this._storeState = {};
}
}
};

View File

@ -29,7 +29,7 @@ loop.standaloneRoomViews = (function(mozL10n) {
onFeedbackSent: function() {
// We pass a tick to prevent React warnings regarding nested updates.
setTimeout(function() {
this.props.activeRoomStore.dispatchAction(new sharedActions.ResetRoom());
this.props.activeRoomStore.dispatchAction(new sharedActions.FeedbackComplete());
}.bind(this));
},
@ -85,8 +85,10 @@ loop.standaloneRoomViews = (function(mozL10n) {
{clientShortname: mozL10n.get("clientShortname2")});
// XXX Bug 1047040 will add images to help prompt the user.
return (
React.DOM.p({className: "prompt-media-message"},
msg
React.DOM.div({className: "room-inner-info-area"},
React.DOM.p({className: "prompt-media-message"},
msg
)
)
);
}

View File

@ -29,7 +29,7 @@ loop.standaloneRoomViews = (function(mozL10n) {
onFeedbackSent: function() {
// We pass a tick to prevent React warnings regarding nested updates.
setTimeout(function() {
this.props.activeRoomStore.dispatchAction(new sharedActions.ResetRoom());
this.props.activeRoomStore.dispatchAction(new sharedActions.FeedbackComplete());
}.bind(this));
},
@ -85,9 +85,11 @@ loop.standaloneRoomViews = (function(mozL10n) {
{clientShortname: mozL10n.get("clientShortname2")});
// XXX Bug 1047040 will add images to help prompt the user.
return (
<p className="prompt-media-message">
{msg}
</p>
<div className="room-inner-info-area">
<p className="prompt-media-message">
{msg}
</p>
</div>
);
}
case ROOM_STATES.JOINED:

View File

@ -690,9 +690,10 @@ loop.webapp = (function($, _, OT, mozL10n) {
return nextState.callStatus !== this.state.callStatus;
},
callStatusSwitcher: function(status) {
resetCallStatus: function() {
this.props.feedbackStore.dispatchAction(new sharedActions.FeedbackComplete());
return function() {
this.setState({callStatus: status});
this.setState({callStatus: "start"});
}.bind(this);
},
@ -744,7 +745,7 @@ loop.webapp = (function($, _, OT, mozL10n) {
sdk: this.props.sdk,
conversation: this.props.conversation,
feedbackStore: this.props.feedbackStore,
onAfterFeedbackReceived: this.callStatusSwitcher("start")}
onAfterFeedbackReceived: this.resetCallStatus()}
)
);
}

View File

@ -690,9 +690,10 @@ loop.webapp = (function($, _, OT, mozL10n) {
return nextState.callStatus !== this.state.callStatus;
},
callStatusSwitcher: function(status) {
resetCallStatus: function() {
this.props.feedbackStore.dispatchAction(new sharedActions.FeedbackComplete());
return function() {
this.setState({callStatus: status});
this.setState({callStatus: "start"});
}.bind(this);
},
@ -744,7 +745,7 @@ loop.webapp = (function($, _, OT, mozL10n) {
sdk={this.props.sdk}
conversation={this.props.conversation}
feedbackStore={this.props.feedbackStore}
onAfterFeedbackReceived={this.callStatusSwitcher("start")}
onAfterFeedbackReceived={this.resetCallStatus()}
/>
);
}

View File

@ -264,7 +264,7 @@ describe("loop.store.ActiveRoomStore", function () {
});
});
describe("#resetRoom", function() {
describe("#feedbackComplete", function() {
it("should reset the room store state", function() {
var initialState = store.getInitialStoreState();
store.setStoreState({
@ -274,7 +274,7 @@ describe("loop.store.ActiveRoomStore", function () {
failureReason: "foo"
});
store.resetRoom(new sharedActions.ResetRoom());
store.feedbackComplete(new sharedActions.FeedbackComplete());
expect(store.getStoreState()).eql(initialState);
});

View File

@ -105,4 +105,16 @@ describe("loop.store.FeedbackStore", function () {
store.sendFeedback(new sharedActions.SendFeedback(sadFeedbackData));
});
});
describe("feedbackComplete", function() {
it("should reset the store state", function() {
store.setStoreState({feedbackState: FEEDBACK_STATES.SENT});
store.feedbackComplete();
expect(store.getStoreState()).eql({
feedbackState: FEEDBACK_STATES.INIT
});
});
});
});

View File

@ -291,21 +291,25 @@ describe("loop.standaloneRoomViews", function() {
});
describe("Feedback", function() {
beforeEach(function() {
activeRoomStore.setStoreState({roomState: ROOM_STATES.ENDED});
});
it("should display a feedback form when the user leaves the room",
function() {
activeRoomStore.setStoreState({roomState: ROOM_STATES.ENDED});
expect(view.getDOMNode().querySelector(".faces")).not.eql(null);
});
it("should reinit the view after feedback is sent", function() {
feedbackStore.setStoreState({feedbackState: FEEDBACK_STATES.SENT});
it("should dispatch a `FeedbackComplete` action after feedback is sent",
function() {
feedbackStore.setStoreState({feedbackState: FEEDBACK_STATES.SENT});
sandbox.clock.tick(
loop.shared.views.WINDOW_AUTOCLOSE_TIMEOUT_IN_SECONDS * 1000);
sandbox.clock.tick(
loop.shared.views.WINDOW_AUTOCLOSE_TIMEOUT_IN_SECONDS * 1000 + 1000);
expect(view.getDOMNode().querySelector(".btn-join")).not.eql(null);
});
sinon.assert.calledOnce(dispatch);
sinon.assert.calledWithExactly(dispatch, new sharedActions.FeedbackComplete());
});
});
});
});