Move sessionStore ref from MatrixChat to LoggedInView

MatrixChat didn't actually use the sessionStore, so this is one less prop to pass.
pull/21833/head
Luke Barnard 2017-05-15 14:56:05 +01:00
parent da3cb0ee48
commit f73cf772fb
2 changed files with 12 additions and 17 deletions

View File

@ -23,6 +23,7 @@ import Notifier from '../../Notifier';
import PageTypes from '../../PageTypes'; import PageTypes from '../../PageTypes';
import sdk from '../../index'; import sdk from '../../index';
import dis from '../../dispatcher'; import dis from '../../dispatcher';
import sessionStore from '../../stores/SessionStore';
/** /**
* This is what our MatrixChat shows when we are logged in. The precise view is * This is what our MatrixChat shows when we are logged in. The precise view is
@ -49,10 +50,6 @@ export default React.createClass({
teamToken: React.PropTypes.string, teamToken: React.PropTypes.string,
// Has the user generated a password that is stored in local storage?
// (are they a PWLU?)
userHasGeneratedPassword: React.PropTypes.bool,
// and lots and lots of other stuff. // and lots and lots of other stuff.
}, },
@ -80,6 +77,10 @@ export default React.createClass({
this._scrollStateMap = {}; this._scrollStateMap = {};
document.addEventListener('keydown', this._onKeyDown); document.addEventListener('keydown', this._onKeyDown);
this._sessionStore = sessionStore;
this._sessionStore.addListener(this._setStateFromSessionStore);
this._setStateFromSessionStore();
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
@ -97,6 +98,12 @@ export default React.createClass({
return this.refs.roomView.canResetTimeline(); return this.refs.roomView.canResetTimeline();
}, },
_setStateFromSessionStore() {
this.setState({
userHasGeneratedPassword: Boolean(this._sessionStore.getCachedPassword()),
});
},
_onKeyDown: function(ev) { _onKeyDown: function(ev) {
/* /*
// Remove this for now as ctrl+alt = alt-gr so this breaks keyboards which rely on alt-gr for numbers // Remove this for now as ctrl+alt = alt-gr so this breaks keyboards which rely on alt-gr for numbers
@ -257,7 +264,7 @@ export default React.createClass({
/>; />;
} else if (this.props.matrixClient.isGuest()) { } else if (this.props.matrixClient.isGuest()) {
topBar = <GuestWarningBar />; topBar = <GuestWarningBar />;
} else if (this.props.userHasGeneratedPassword) { } else if (this.state.userHasGeneratedPassword) {
topBar = <PasswordNagBar />; topBar = <PasswordNagBar />;
} else if (Notifier.supportsDesktopNotifications() && !Notifier.isEnabled() && !Notifier.isToolbarHidden()) { } else if (Notifier.supportsDesktopNotifications() && !Notifier.isEnabled() && !Notifier.isToolbarHidden()) {
topBar = <MatrixToolbar />; topBar = <MatrixToolbar />;

View File

@ -40,8 +40,6 @@ var PageTypes = require('../../PageTypes');
var createRoom = require("../../createRoom"); var createRoom = require("../../createRoom");
import * as UDEHandler from '../../UnknownDeviceErrorHandler'; import * as UDEHandler from '../../UnknownDeviceErrorHandler';
import sessionStore from '../../stores/SessionStore';
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'MatrixChat', displayName: 'MatrixChat',
@ -250,10 +248,6 @@ module.exports = React.createClass({
register_hs_url: paramHs, register_hs_url: paramHs,
}); });
} }
this._sessionStore = sessionStore;
this._sessionStore.addListener(this._setStateFromSessionStore);
this._setStateFromSessionStore();
}, },
componentDidMount: function() { componentDidMount: function() {
@ -897,12 +891,6 @@ module.exports = React.createClass({
}); });
}, },
_setStateFromSessionStore() {
this.setState({
userHasGeneratedPassword: Boolean(this._sessionStore.getCachedPassword()),
});
},
onFocus: function(ev) { onFocus: function(ev) {
dis.dispatch({action: 'focus_composer'}); dis.dispatch({action: 'focus_composer'});
}, },