@@ -1358,7 +1422,7 @@ module.exports = React.createClass({
}
// needs to be before normal PageTypes as you are logged in technically
- if (this.state.screen == 'post_registration') {
+ if (this.state.view === VIEWS.POST_REGISTRATION) {
const PostRegistration = sdk.getComponent('structures.login.PostRegistration');
return (
- );
- } else if (this.state.loggedIn) {
- // we think we are logged in, but are still waiting for the /sync to complete
- const Spinner = sdk.getComponent('elements.Spinner');
- return (
-
- );
- } else if (this.state.screen == 'register') {
+ if (this.state.view === VIEWS.LOGGED_IN) {
+ // `ready` and `view==LOGGED_IN` may be set before `page_type` (because the
+ // latter is set via the dispatcher). If we don't yet have a `page_type`,
+ // keep showing the spinner for now.
+ if (this.state.ready && this.state.page_type) {
+ /* for now, we stuff the entirety of our props and state into the LoggedInView.
+ * we should go through and figure out what we actually need to pass down, as well
+ * as using something like redux to avoid having a billion bits of state kicking around.
+ */
+ const LoggedInView = sdk.getComponent('structures.LoggedInView');
+ return (
+
+ );
+ } else {
+ // we think we are logged in, but are still waiting for the /sync to complete
+ const Spinner = sdk.getComponent('elements.Spinner');
+ return (
+
+ );
+ }
+ }
+
+ if (this.state.view === VIEWS.REGISTER) {
const Registration = sdk.getComponent('structures.login.Registration');
return (
);
- } else if (this.state.screen == 'forgot_password') {
+ }
+
+
+ if (this.state.view === VIEWS.FORGOT_PASSWORD) {
const ForgotPassword = sdk.getComponent('structures.login.ForgotPassword');
return (
);
- } else {
+ }
+
+ if (this.state.view === VIEWS.LOGIN) {
const Login = sdk.getComponent('structures.login.Login');
return (
);
}
+
+ console.error(`Unknown view ${this.state.view}`);
},
});
diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js
index 9306008e71..b29b3579f0 100644
--- a/src/components/structures/RoomView.js
+++ b/src/components/structures/RoomView.js
@@ -93,6 +93,7 @@ module.exports = React.createClass({
roomId: null,
roomLoading: true,
peekLoading: false,
+ shouldPeek: true,
// The event to be scrolled to initially
initialEventId: null,
@@ -168,8 +169,14 @@ module.exports = React.createClass({
initialEventId: RoomViewStore.getInitialEventId(),
initialEventPixelOffset: RoomViewStore.getInitialEventPixelOffset(),
isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(),
+ forwardingEvent: RoomViewStore.getForwardingEvent(),
+ shouldPeek: RoomViewStore.shouldPeek(),
};
+ // finished joining, start waiting for a room and show a spinner. See onRoom.
+ newState.waitingForRoom = this.state.joining && !newState.joining &&
+ !RoomViewStore.getJoinError();
+
// Temporary logging to diagnose https://github.com/vector-im/riot-web/issues/4307
console.log(
'RVS update:',
@@ -177,12 +184,11 @@ module.exports = React.createClass({
newState.roomAlias,
'loading?', newState.roomLoading,
'joining?', newState.joining,
+ 'initial?', initial,
+ 'waiting?', newState.waitingForRoom,
+ 'shouldPeek?', newState.shouldPeek,
);
- // finished joining, start waiting for a room and show a spinner. See onRoom.
- newState.waitingForRoom = this.state.joining && !newState.joining &&
- !RoomViewStore.getJoinError();
-
// NB: This does assume that the roomID will not change for the lifetime of
// the RoomView instance
if (initial) {
@@ -238,7 +244,7 @@ module.exports = React.createClass({
if (!this.state.joining && this.state.roomId) {
if (this.props.autoJoin) {
this.onJoinButtonClicked();
- } else if (!room) {
+ } else if (!room && this.state.shouldPeek) {
console.log("Attempting to peek into room %s", this.state.roomId);
this.setState({
peekLoading: true,
@@ -452,11 +458,6 @@ module.exports = React.createClass({
callState: callState
});
- break;
- case 'forward_event':
- this.setState({
- forwardingEvent: payload.content,
- });
break;
}
},
@@ -1164,8 +1165,13 @@ module.exports = React.createClass({
this.updateTint();
this.setState({
editingRoomSettings: false,
- forwardingEvent: null,
});
+ if (this.state.forwardingEvent) {
+ dis.dispatch({
+ action: 'forward_event',
+ event: null,
+ });
+ }
dis.dispatch({action: 'focus_composer'});
},
@@ -1576,7 +1582,7 @@ module.exports = React.createClass({
} else if (this.state.uploadingRoomSettings) {
aux =
;
} else if (this.state.forwardingEvent !== null) {
- aux =
;
+ aux =
;
} else if (this.state.searching) {
hideCancel = true; // has own cancel
aux =
;
diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js
index fc13f0bdcf..9a5eb07cde 100644
--- a/src/components/structures/UserSettings.js
+++ b/src/components/structures/UserSettings.js
@@ -21,6 +21,7 @@ const MatrixClientPeg = require("../../MatrixClientPeg");
const PlatformPeg = require("../../PlatformPeg");
const Modal = require('../../Modal');
const dis = require("../../dispatcher");
+import sessionStore from '../../stores/SessionStore';
const q = require('q');
const packageJson = require('../../../package.json');
const UserSettingsStore = require('../../UserSettingsStore');
@@ -243,6 +244,12 @@ module.exports = React.createClass({
this.setState({
language: languageHandler.getCurrentLanguage(),
});
+
+ this._sessionStore = sessionStore;
+ this._sessionStoreToken = this._sessionStore.addListener(
+ this._setStateFromSessionStore,
+ );
+ this._setStateFromSessionStore();
},
componentDidMount: function() {
@@ -269,6 +276,22 @@ module.exports = React.createClass({
}
},
+ // `UserSettings` assumes that the client peg will not be null, so give it some
+ // sort of assurance here by only allowing a re-render if the client is truthy.
+ //
+ // This is required because `UserSettings` maintains its own state and if this state
+ // updates (e.g. during _setStateFromSessionStore) after the client peg has been made
+ // null (during logout), then it will attempt to re-render and throw errors.
+ shouldComponentUpdate: function() {
+ return Boolean(MatrixClientPeg.get());
+ },
+
+ _setStateFromSessionStore: function() {
+ this.setState({
+ userHasGeneratedPassword: Boolean(this._sessionStore.getCachedPassword()),
+ });
+ },
+
_electronSettings: function(ev, settings) {
this.setState({ electron_settings: settings });
},
@@ -861,6 +884,21 @@ module.exports = React.createClass({
;
},
+ _renderCheckUpdate: function() {
+ const platform = PlatformPeg.get();
+ if ('canSelfUpdate' in platform && platform.canSelfUpdate() && 'startUpdateCheck' in platform) {
+ return