diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 542b7a3e50..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, @@ -169,8 +170,13 @@ module.exports = React.createClass({ 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:', @@ -178,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) { @@ -239,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, diff --git a/src/createRoom.js b/src/createRoom.js index 4d7f5792f3..bf0c0fee1c 100644 --- a/src/createRoom.js +++ b/src/createRoom.js @@ -100,6 +100,7 @@ function createRoom(opts) { dis.dispatch({ action: 'view_room', room_id: roomId, + should_peek: false, }); } return roomId; diff --git a/src/stores/RoomViewStore.js b/src/stores/RoomViewStore.js index d68373f0d5..2f7d55b71f 100644 --- a/src/stores/RoomViewStore.js +++ b/src/stores/RoomViewStore.js @@ -137,6 +137,8 @@ class RoomViewStore extends Store { forwardingEvent: null, roomLoading: false, roomLoadError: null, + // should peek by default + shouldPeek: payload.should_peek === undefined ? true : payload.should_peek, }; // If an event ID wasn't specified, default to the one saved for this room @@ -297,6 +299,10 @@ class RoomViewStore extends Store { getForwardingEvent() { return this._state.forwardingEvent; } + + shouldPeek() { + return this._state.shouldPeek; + } } let singletonRoomViewStore = null;