Merge pull request #1517 from matrix-org/luke/groups-invalidate-flair-cache

Invalidate the user's public groups cache when changing group publicity
pull/21833/head
Luke Barnard 2017-10-23 15:59:33 +01:00 committed by GitHub
commit 59c5dfda86
2 changed files with 6 additions and 0 deletions

View File

@ -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]);

View File

@ -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));
}
}