diff --git a/browser/components/loop/LoopRooms.jsm b/browser/components/loop/LoopRooms.jsm index cff23aeb0794..d3374c2d615c 100644 --- a/browser/components/loop/LoopRooms.jsm +++ b/browser/components/loop/LoopRooms.jsm @@ -638,6 +638,37 @@ let LoopRoomsInternal = { }, callback); }, + /** + * Forwards connection status to the server. + * + * @param {String} roomToken The room token. + * @param {String} sessionToken The session token for the + * session that has been + * joined. + * @param {sharedActions.SdkStatus} status The connection status. + * @param {Function} callback Optional. Function that will be invoked once + * the operation finished. The first argument + * passed will be an `Error` object or `null`. + */ + sendConnectionStatus: function(roomToken, sessionToken, status, callback) { + if (!callback) { + callback = function(error) { + if (error) { + MozLoopService.log.error(error); + } + }; + } + this._postToRoom(roomToken, { + action: "status", + event: status.event, + state: status.state, + connections: status.connections, + sendStreams: status.sendStreams, + recvStreams: status.recvStreams, + sessionToken: sessionToken + }, callback); + }, + /** * Renames a room. * @@ -780,6 +811,10 @@ this.LoopRooms = { return LoopRoomsInternal.leave(roomToken, sessionToken, callback); }, + sendConnectionStatus: function(roomToken, sessionToken, status, callback) { + return LoopRoomsInternal.sendConnectionStatus(roomToken, sessionToken, status, callback); + }, + rename: function(roomToken, newRoomName, callback) { return LoopRoomsInternal.rename(roomToken, newRoomName, callback); }, diff --git a/browser/components/loop/content/js/panel.js b/browser/components/loop/content/js/panel.js index 6f2e05a8ebe9..b18bcc0e4858 100644 --- a/browser/components/loop/content/js/panel.js +++ b/browser/components/loop/content/js/panel.js @@ -432,6 +432,8 @@ loop.panel = (function(_, mozL10n) { }); var RoomEntryContextItem = React.createClass({displayName: "RoomEntryContextItem", + mixins: [loop.shared.mixins.WindowCloseMixin], + propTypes: { mozLoop: React.PropTypes.object.isRequired, roomUrls: React.PropTypes.object @@ -441,6 +443,7 @@ loop.panel = (function(_, mozL10n) { event.stopPropagation(); event.preventDefault(); this.props.mozLoop.openURL(event.currentTarget.href); + this.closeWindow(); }, render: function() { @@ -700,9 +703,17 @@ loop.panel = (function(_, mozL10n) { }, render: function() { + var hostname; + + try { + hostname = new URL(this.state.url).hostname; + } catch (ex) { + // Empty catch - if there's an error, then we won't show the context. + } + var contextClasses = React.addons.classSet({ context: true, - hide: !this.state.url || + hide: !hostname || !this.props.mozLoop.getLoopPref("contextInConverations.enabled") }); @@ -716,7 +727,7 @@ loop.panel = (function(_, mozL10n) { ), React.createElement("img", {className: "context-preview", src: this.state.previewImage}), React.createElement("span", {className: "context-description"}, this.state.description), - React.createElement("span", {className: "context-url"}, this.state.url) + React.createElement("span", {className: "context-url"}, hostname) ), React.createElement("button", {className: "btn btn-info new-room-button", onClick: this.handleCreateButtonClick, diff --git a/browser/components/loop/content/js/panel.jsx b/browser/components/loop/content/js/panel.jsx index b45700ccd323..7d0e8b84ca6b 100644 --- a/browser/components/loop/content/js/panel.jsx +++ b/browser/components/loop/content/js/panel.jsx @@ -432,6 +432,8 @@ loop.panel = (function(_, mozL10n) { }); var RoomEntryContextItem = React.createClass({ + mixins: [loop.shared.mixins.WindowCloseMixin], + propTypes: { mozLoop: React.PropTypes.object.isRequired, roomUrls: React.PropTypes.object @@ -441,6 +443,7 @@ loop.panel = (function(_, mozL10n) { event.stopPropagation(); event.preventDefault(); this.props.mozLoop.openURL(event.currentTarget.href); + this.closeWindow(); }, render: function() { @@ -700,9 +703,17 @@ loop.panel = (function(_, mozL10n) { }, render: function() { + var hostname; + + try { + hostname = new URL(this.state.url).hostname; + } catch (ex) { + // Empty catch - if there's an error, then we won't show the context. + } + var contextClasses = React.addons.classSet({ context: true, - hide: !this.state.url || + hide: !hostname || !this.props.mozLoop.getLoopPref("contextInConverations.enabled") }); @@ -716,7 +727,7 @@ loop.panel = (function(_, mozL10n) { {this.state.description} - {this.state.url} + {hostname}