Merge pull request #4606 from matrix-org/t3chguy/peeking-races

Fix room alias lookup vs peeking race condition
This commit is contained in:
Michael Telatynski 2020-05-27 17:07:12 +01:00 committed by GitHub
commit 0fd5714e21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 14 deletions

View file

@ -46,7 +46,6 @@ const INITIAL_STATE = {
forwardingEvent: null,
quotingEvent: null,
matrixClientIsReady: false,
};
/**
@ -60,9 +59,6 @@ class RoomViewStore extends Store {
// Initialise state
this._state = INITIAL_STATE;
if (MatrixClientPeg.get()) {
this._state.matrixClientIsReady = MatrixClientPeg.get().isInitialSyncComplete();
}
}
_setState(newState) {
@ -157,11 +153,6 @@ class RoomViewStore extends Store {
}, /*className=*/null, /*isPriority=*/false, /*isStatic=*/true);
break;
}
case 'sync_state':
this._setState({
matrixClientIsReady: MatrixClientPeg.get() && MatrixClientPeg.get().isInitialSyncComplete(),
});
break;
}
}
@ -224,6 +215,7 @@ class RoomViewStore extends Store {
storeRoomAliasInCache(payload.room_alias, result.room_id);
roomId = result.room_id;
} catch (err) {
console.error("RVS failed to get room id for alias: ", err);
dis.dispatch({
action: 'view_room_error',
room_id: null,
@ -374,7 +366,7 @@ class RoomViewStore extends Store {
}
shouldPeek() {
return this._state.shouldPeek && this._state.matrixClientIsReady;
return this._state.shouldPeek;
}
}