Short-circuit room list store dispatch handling if not ready
We were taking 0.2ms to handle the registration of a timer per event during startup, even before the app is visible to the user. These timers would be short-circuited too, leading to a bunch of wasted time. 0.2ms isn't a lot of time, but multiplied by thousands of events at startup it's pretty significant. On my account this reduces the full page spinner time from ~50 seconds to just over 20 seconds.
This commit is contained in:
parent
f27afc6ff8
commit
c22cb6c325
1 changed files with 6 additions and 0 deletions
|
@ -168,6 +168,12 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async onAction(payload: ActionPayload) {
|
protected async onAction(payload: ActionPayload) {
|
||||||
|
// If we're not remotely ready, don't even bother scheduling the dispatch handling.
|
||||||
|
// This is repeated in the handler just in case things change between a decision here and
|
||||||
|
// when the timer fires.
|
||||||
|
const logicallyReady = this.matrixClient && this.initialListsGenerated;
|
||||||
|
if (!logicallyReady) return;
|
||||||
|
|
||||||
// When we're running tests we can't reliably use setImmediate out of timing concerns.
|
// When we're running tests we can't reliably use setImmediate out of timing concerns.
|
||||||
// As such, we use a more synchronous model.
|
// As such, we use a more synchronous model.
|
||||||
if (RoomListStoreClass.TEST_MODE) {
|
if (RoomListStoreClass.TEST_MODE) {
|
||||||
|
|
Loading…
Reference in a new issue