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

Commit

Permalink
Don't peek until the matrix client is ready
Browse files Browse the repository at this point in the history
When the client loaded, we'd load the room view which would try to
get a room object from the client, fail because the client wasn't
ready, think it's because the user wasn't joined to the room and
start peeking instead.

Coupled with the bug fixed by matrix-org/matrix-js-sdk#1188
this would have caused element-hq/element-web#11120
  • Loading branch information
dbkr committed Jan 29, 2020
1 parent 45735d5 commit b96ad4a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/stores/RoomViewStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const INITIAL_STATE = {
forwardingEvent: null,

quotingEvent: null,
matrixClientIsReady: false,
};

/**
Expand All @@ -59,6 +60,9 @@ class RoomViewStore extends Store {

// Initialise state
this._state = INITIAL_STATE;
if (MatrixClientPeg.get()) {
this._state.matrixClientIsReady = MatrixClientPeg.get().isInitialSyncComplete();
}
}

_setState(newState) {
Expand Down Expand Up @@ -136,6 +140,11 @@ class RoomViewStore extends Store {
}, /*className=*/null, /*isPriority=*/false, /*isStatic=*/true);
break;
}
case 'sync_state':
this._setState({
matrixClientIsReady: MatrixClientPeg.get().isInitialSyncComplete(),
});
break;
}
}

Expand Down Expand Up @@ -350,7 +359,7 @@ class RoomViewStore extends Store {
}

shouldPeek() {
return this._state.shouldPeek;
return this._state.shouldPeek && this._state.matrixClientIsReady;
}
}

Expand Down

0 comments on commit b96ad4a

Please sign in to comment.