Move sessionStore ref from MatrixChat to LoggedInView

MatrixChat didn't actually use the sessionStore, so this is one less prop to pass.
This commit is contained in:
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 sdk from '../../index';
import dis from '../../dispatcher';
import sessionStore from '../../stores/SessionStore';
/**
* 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,
// 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.
},
@ -80,6 +77,10 @@ export default React.createClass({
this._scrollStateMap = {};
document.addEventListener('keydown', this._onKeyDown);
this._sessionStore = sessionStore;
this._sessionStore.addListener(this._setStateFromSessionStore);
this._setStateFromSessionStore();
},
componentWillUnmount: function() {
@ -97,6 +98,12 @@ export default React.createClass({
return this.refs.roomView.canResetTimeline();
},
_setStateFromSessionStore() {
this.setState({
userHasGeneratedPassword: Boolean(this._sessionStore.getCachedPassword()),
});
},
_onKeyDown: function(ev) {
/*
// 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()) {
topBar = <GuestWarningBar />;
} else if (this.props.userHasGeneratedPassword) {
} else if (this.state.userHasGeneratedPassword) {
topBar = <PasswordNagBar />;
} else if (Notifier.supportsDesktopNotifications() && !Notifier.isEnabled() && !Notifier.isToolbarHidden()) {
topBar = <MatrixToolbar />;

View file

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