From d64fc4c842ca993b10b9a7e764d481c4c5fbe4ed Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 3 Nov 2017 18:19:10 +0000 Subject: [PATCH 1/3] Fix Flair not appearing due to missing this._usersInFlight --- src/stores/FlairStore.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/stores/FlairStore.js b/src/stores/FlairStore.js index 9424503390a..411065eee06 100644 --- a/src/stores/FlairStore.js +++ b/src/stores/FlairStore.js @@ -48,6 +48,9 @@ class FlairStore extends EventEmitter { // reject: () => {} // } }; + this._usersInFlight = { + // see _usersPending + }; this._debounceTimeoutID = null; } From 4d8f18742b5dc1563f58867604e215a7685df411 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 3 Nov 2017 18:43:43 +0000 Subject: [PATCH 2/3] Check against non-existant promise to resolve a user's groups --- src/stores/FlairStore.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/stores/FlairStore.js b/src/stores/FlairStore.js index 411065eee06..587890da7fa 100644 --- a/src/stores/FlairStore.js +++ b/src/stores/FlairStore.js @@ -128,12 +128,16 @@ class FlairStore extends EventEmitter { } catch (err) { // Propagate the same error to all usersInFlight Object.keys(this._usersInFlight).forEach((userId) => { + // The promise should always exist for userId, but do a null-check anyway + if (!this._usersInFlight[userId]) return; this._usersInFlight[userId].reject(err); }); return; } const updatedUserGroups = resp.users; Object.keys(this._usersInFlight).forEach((userId) => { + // The promise should always exist for userId, but do a null-check anyway + if (!this._usersInFlight[userId]) return; this._usersInFlight[userId].resolve(updatedUserGroups[userId] || []); }); } From da23afdec228fff34c24dd8b923f8b0490078e7b Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 3 Nov 2017 18:48:15 +0000 Subject: [PATCH 3/3] Better comment on FlairStore _usersInFlight --- src/stores/FlairStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/FlairStore.js b/src/stores/FlairStore.js index 587890da7fa..1d20148c0dd 100644 --- a/src/stores/FlairStore.js +++ b/src/stores/FlairStore.js @@ -49,7 +49,7 @@ class FlairStore extends EventEmitter { // } }; this._usersInFlight = { - // see _usersPending + // This has the same schema as _usersPending }; this._debounceTimeoutID = null;