Fix to allow subsequent group profile requests if one fails

Also, delete the groupProfilePromise immediately after setting
the group profile (the first if-statement will prevent a new
request from being started).
pull/21833/head
lukebarnard 2018-01-02 10:22:34 +00:00
parent 6e832c7d73
commit 3947a72d1b
1 changed files with 10 additions and 2 deletions

View File

@ -157,17 +157,25 @@ class FlairStore {
this._groupProfilesPromise[groupId] = matrixClient.getGroupProfile(groupId);
}
const profile = await this._groupProfilesPromise[groupId];
let profile;
try {
profile = await this._groupProfilesPromise[groupId];
} catch (e) {
// Don't retry, but allow a retry when the profile is next requested
delete this._groupProfilesPromise[groupId];
return;
}
this._groupProfiles[groupId] = {
groupId,
avatarUrl: profile.avatar_url,
name: profile.name,
shortDescription: profile.short_description,
};
delete this._groupProfilesPromise[groupId];
setTimeout(() => {
delete this._groupProfiles[groupId];
delete this._groupProfilesPromise[groupId];
}, GROUP_PROFILES_CACHE_BUST_MS);
return this._groupProfiles[groupId];