Bug 1158800 - Don't show errors for context in conversations on the standalone UI as they may force the user into an unnecessary re-obtaining of the URL. r=dmose

This commit is contained in:
Mark Banner 2015-04-28 08:17:56 +01:00
parent 6744904f95
commit 5f6f17db3a
3 changed files with 43 additions and 15 deletions

View File

@ -280,15 +280,28 @@ loop.standaloneRoomViews = (function(mozL10n) {
roomInfoFailure: React.PropTypes.string
},
getInitialState: function() {
return {
failureLogged: false
}
},
_logFailure: function(message) {
if (!this.state.failureLogged) {
console.error(mozL10n.get(message));
this.state.failureLogged = true;
}
},
render: function() {
// For failures, we currently just log the messages - UX doesn't want them
// displayed on primary UI at the moment.
if (this.props.roomInfoFailure === ROOM_INFO_FAILURES.WEB_CRYPTO_UNSUPPORTED) {
return (React.createElement("h2", {className: "room-info-failure"},
mozL10n.get("room_information_failure_unsupported_browser")
));
this._logFailure("room_information_failure_unsupported_browser");
return null;
} else if (this.props.roomInfoFailure) {
return (React.createElement("h2", {className: "room-info-failure"},
mozL10n.get("room_information_failure_not_available")
));
this._logFailure("room_information_failure_not_available");
return null;
}
// We only support one item in the context Urls array for now.

View File

@ -280,15 +280,28 @@ loop.standaloneRoomViews = (function(mozL10n) {
roomInfoFailure: React.PropTypes.string
},
getInitialState: function() {
return {
failureLogged: false
}
},
_logFailure: function(message) {
if (!this.state.failureLogged) {
console.error(mozL10n.get(message));
this.state.failureLogged = true;
}
},
render: function() {
// For failures, we currently just log the messages - UX doesn't want them
// displayed on primary UI at the moment.
if (this.props.roomInfoFailure === ROOM_INFO_FAILURES.WEB_CRYPTO_UNSUPPORTED) {
return (<h2 className="room-info-failure">
{mozL10n.get("room_information_failure_unsupported_browser")}
</h2>);
this._logFailure("room_information_failure_unsupported_browser");
return null;
} else if (this.props.roomInfoFailure) {
return (<h2 className="room-info-failure">
{mozL10n.get("room_information_failure_not_available")}
</h2>);
this._logFailure("room_information_failure_not_available");
return null;
}
// We only support one item in the context Urls array for now.

View File

@ -63,13 +63,14 @@ describe("loop.standaloneRoomViews", function() {
expect(view.getDOMNode().textContent).eql("Mike's room");
});
it("should display an unsupported browser message if crypto is unsupported", function() {
it("should log an unsupported browser message if crypto is unsupported", function() {
var view = mountTestComponent({
roomName: "Mark's room",
roomInfoFailure: ROOM_INFO_FAILURES.WEB_CRYPTO_UNSUPPORTED
});
expect(view.getDOMNode().textContent).match(/unsupported/);
sinon.assert.called(console.error);
sinon.assert.calledWithMatch(console.error, sinon.match("unsupported"));
});
it("should display a general error message for any other failure", function() {
@ -78,7 +79,8 @@ describe("loop.standaloneRoomViews", function() {
roomInfoFailure: ROOM_INFO_FAILURES.NO_DATA
});
expect(view.getDOMNode().textContent).match(/not_available/);
sinon.assert.called(console.error);
sinon.assert.calledWithMatch(console.error, sinon.match("not_available"));
});
it("should display context information if a url is supplied", function() {