Use FlairStore's cache for group naming

Turns out GroupStore doesn't really know much.
This commit is contained in:
Travis Ralston 2020-08-28 14:56:59 -06:00
parent e68c4efd0b
commit 90d9d7128d
5 changed files with 34 additions and 10 deletions

View file

@ -148,6 +148,22 @@ class FlairStore extends EventEmitter {
});
}
/**
* Gets the profile for the given group if known, otherwise returns null.
* This triggers `getGroupProfileCached` if needed, though the result of the
* call will not be returned by this function.
* @param matrixClient The matrix client to use to fetch the profile, if needed.
* @param groupId The group ID to get the profile for.
* @returns The profile if known, otherwise null.
*/
getGroupProfileCachedFast(matrixClient, groupId) {
if (this._groupProfiles[groupId]) {
return this._groupProfiles[groupId];
}
this.getGroupProfileCached(matrixClient, groupId);
return null;
}
async getGroupProfileCached(matrixClient, groupId) {
if (this._groupProfiles[groupId]) {
return this._groupProfiles[groupId];