Check against non-existant promise to resolve a user's groups
This commit is contained in:
parent
d64fc4c842
commit
4d8f18742b
1 changed files with 4 additions and 0 deletions
|
@ -128,12 +128,16 @@ class FlairStore extends EventEmitter {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Propagate the same error to all usersInFlight
|
// Propagate the same error to all usersInFlight
|
||||||
Object.keys(this._usersInFlight).forEach((userId) => {
|
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);
|
this._usersInFlight[userId].reject(err);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const updatedUserGroups = resp.users;
|
const updatedUserGroups = resp.users;
|
||||||
Object.keys(this._usersInFlight).forEach((userId) => {
|
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] || []);
|
this._usersInFlight[userId].resolve(updatedUserGroups[userId] || []);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue