From 3947a72d1b1380bea77d3cbaaad3e23690476161 Mon Sep 17 00:00:00 2001 From: lukebarnard Date: Tue, 2 Jan 2018 10:22:34 +0000 Subject: [PATCH] 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). --- src/stores/FlairStore.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/stores/FlairStore.js b/src/stores/FlairStore.js index e9e84e9aa1..7ffa1a4c30 100644 --- a/src/stores/FlairStore.js +++ b/src/stores/FlairStore.js @@ -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];