Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 467c195

Browse files
Luke Barnarddbkr
authored andcommitted
Don't peek when creating a room
This causes a race between receiving the room when starting to peek and receiving the room from joining it - element-hq/element-web#4330, element-hq/element-web-rageshakes#196
1 parent 27f38ae commit 467c195

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/components/structures/RoomView.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ module.exports = React.createClass({
9393
roomId: null,
9494
roomLoading: true,
9595
peekLoading: false,
96+
shouldPeek: true,
9697

9798
// The event to be scrolled to initially
9899
initialEventId: null,
@@ -169,21 +170,25 @@ module.exports = React.createClass({
169170
initialEventPixelOffset: RoomViewStore.getInitialEventPixelOffset(),
170171
isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(),
171172
forwardingEvent: RoomViewStore.getForwardingEvent(),
173+
shouldPeek: RoomViewStore.shouldPeek(),
172174
};
173175

176+
// finished joining, start waiting for a room and show a spinner. See onRoom.
177+
newState.waitingForRoom = this.state.joining && !newState.joining &&
178+
!RoomViewStore.getJoinError();
179+
174180
// Temporary logging to diagnose https://github.com/vector-im/riot-web/issues/4307
175181
console.log(
176182
'RVS update:',
177183
newState.roomId,
178184
newState.roomAlias,
179185
'loading?', newState.roomLoading,
180186
'joining?', newState.joining,
187+
'initial?', initial,
188+
'waiting?', newState.waitingForRoom,
189+
'shouldPeek?', newState.shouldPeek,
181190
);
182191

183-
// finished joining, start waiting for a room and show a spinner. See onRoom.
184-
newState.waitingForRoom = this.state.joining && !newState.joining &&
185-
!RoomViewStore.getJoinError();
186-
187192
// NB: This does assume that the roomID will not change for the lifetime of
188193
// the RoomView instance
189194
if (initial) {
@@ -239,7 +244,7 @@ module.exports = React.createClass({
239244
if (!this.state.joining && this.state.roomId) {
240245
if (this.props.autoJoin) {
241246
this.onJoinButtonClicked();
242-
} else if (!room) {
247+
} else if (!room && this.state.shouldPeek) {
243248
console.log("Attempting to peek into room %s", this.state.roomId);
244249
this.setState({
245250
peekLoading: true,

src/createRoom.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ function createRoom(opts) {
100100
dis.dispatch({
101101
action: 'view_room',
102102
room_id: roomId,
103+
should_peek: false,
103104
});
104105
}
105106
return roomId;

src/stores/RoomViewStore.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ class RoomViewStore extends Store {
137137
forwardingEvent: null,
138138
roomLoading: false,
139139
roomLoadError: null,
140+
// should peek by default
141+
shouldPeek: payload.should_peek === undefined ? true : payload.should_peek,
140142
};
141143

142144
// If an event ID wasn't specified, default to the one saved for this room
@@ -297,6 +299,10 @@ class RoomViewStore extends Store {
297299
getForwardingEvent() {
298300
return this._state.forwardingEvent;
299301
}
302+
303+
shouldPeek() {
304+
return this._state.shouldPeek;
305+
}
300306
}
301307

302308
let singletonRoomViewStore = null;

0 commit comments

Comments
 (0)