From 0ff5b9c6a71de35a29c0a9544b56a1f25a04192c Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Mon, 23 Oct 2017 15:28:38 +0100 Subject: [PATCH] Invalidate the user's public groups cache when changing group publicity This will make the changes to their Flair "live", but only from the user's own perspective. --- src/stores/FlairStore.js | 4 ++++ src/stores/GroupStore.js | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/stores/FlairStore.js b/src/stores/FlairStore.js index f9d9af75a9..1ac518a4f6 100644 --- a/src/stores/FlairStore.js +++ b/src/stores/FlairStore.js @@ -56,6 +56,10 @@ class FlairStore extends EventEmitter { return groupSupport; } + invalidatePublicisedGroups(userId) { + delete this._userGroups[userId]; + } + getPublicisedGroupsCached(matrixClient, userId) { if (this._userGroups[userId]) { return Promise.resolve(this._userGroups[userId]); diff --git a/src/stores/GroupStore.js b/src/stores/GroupStore.js index c1ef4619cd..da27bd10e8 100644 --- a/src/stores/GroupStore.js +++ b/src/stores/GroupStore.js @@ -15,6 +15,7 @@ limitations under the License. */ import EventEmitter from 'events'; +import FlairStore from './FlairStore'; /** * Stores the group summary for a room and provides an API to change it and @@ -110,6 +111,7 @@ export default class GroupStore extends EventEmitter { setGroupPublicity(isPublished) { return this._matrixClient .setGroupPublicity(this.groupId, isPublished) + .then(() => { FlairStore.invalidatePublicisedGroups(this._matrixClient.credentials.userId); }) .then(this._fetchSummary.bind(this)); } }