From 15e37c5b0df16cef90700ebb3e4ac14a22de5936 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Mon, 1 Mar 2021 16:11:11 +0000 Subject: [PATCH 1/2] Invalidate the state cache when new room state appears --- src/components/client-request-cache.ts | 4 ++++ src/components/intent.ts | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/client-request-cache.ts b/src/components/client-request-cache.ts index f6c9d274..66b40fcb 100644 --- a/src/components/client-request-cache.ts +++ b/src/components/client-request-cache.ts @@ -38,6 +38,10 @@ export class ClientRequestCache> { } } + invalidate(key: string) { + this.requestContent.delete(key); + } + /** * Gets a result of a request from the cache, or otherwise * tries to fetch the the result with this.requestFunc diff --git a/src/components/intent.ts b/src/components/intent.ts index 4dce2bd9..4a299a44 100644 --- a/src/components/intent.ts +++ b/src/components/intent.ts @@ -806,13 +806,16 @@ export class Intent { // eslint-disable-next-line camelcase room_id: string }) { - if (!this._membershipStates || !this._powerLevels) { - return; - } if (event.state_key === undefined) { // We MUST operate on state events exclusively return; } + // Invalidate the state cache if anything changes in the state. + this._requestCaches.roomstate.invalidate(event.room_id); + if (!this._membershipStates || !this._powerLevels) { + return; + } + if (event.type === "m.room.member" && event.state_key === this.userId && event.content.membership) { From 6360d967c906abc2c83e1c5ca785498e30ece244 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Mon, 1 Mar 2021 16:12:32 +0000 Subject: [PATCH 2/2] changelog --- changelog.d/310.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/310.bugfix diff --git a/changelog.d/310.bugfix b/changelog.d/310.bugfix new file mode 100644 index 00000000..3ed355fb --- /dev/null +++ b/changelog.d/310.bugfix @@ -0,0 +1 @@ +Ensure that the Intent room state cache is invalidate when the room state changes. \ No newline at end of file