gecko-dev/browser/components/loop/content/js/roomViews.js
Nicolas Perriault 8671517f49 Bug 1093620 - Using a single root store for Loop rooms. r=Standard8
--HG--
rename : browser/components/loop/content/shared/js/localRoomStore.js => browser/components/loop/content/shared/js/activeRoomStore.js
rename : browser/components/loop/content/shared/js/roomListStore.js => browser/components/loop/content/shared/js/roomStore.js
rename : browser/components/loop/test/shared/localRoomStore_test.js => browser/components/loop/test/shared/activeRoomStore_test.js
rename : browser/components/loop/test/shared/roomListStore_test.js => browser/components/loop/test/shared/roomStore_test.js
2014-11-05 13:59:46 +00:00

59 lines
1.5 KiB
JavaScript

/** @jsx React.DOM */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* global loop:true, React */
var loop = loop || {};
loop.roomViews = (function(mozL10n) {
"use strict";
var DesktopRoomView = React.createClass({displayName: 'DesktopRoomView',
mixins: [Backbone.Events, loop.shared.mixins.DocumentTitleMixin],
propTypes: {
mozLoop: React.PropTypes.object.isRequired,
roomStore: React.PropTypes.instanceOf(loop.store.RoomStore).isRequired,
},
getInitialState: function() {
return this.props.roomStore.getStoreState();
},
componentWillMount: function() {
this.listenTo(this.props.roomStore, "change:activeRoom",
this._onActiveRoomStateChanged);
},
/**
* Handles a "change" event on the roomStore, and updates this.state
* to match the store.
*
* @private
*/
_onActiveRoomStateChanged: function() {
this.setState(this.props.roomStore.getStoreState("activeRoom"));
},
componentWillUnmount: function() {
this.stopListening(this.props.roomStore);
},
render: function() {
if (this.state.serverData && this.state.serverData.roomName) {
this.setTitle(this.state.serverData.roomName);
}
return (
React.DOM.div({className: "goat"})
);
}
});
return {
DesktopRoomView: DesktopRoomView
};
})(document.mozL10n || navigator.mozL10n);