1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00

add comment to clarify how we avoid race

This commit is contained in:
Bruno Windels
2018-07-19 16:32:18 +02:00
parent d366ec9c48
commit 2b9c834476

View File

@@ -781,6 +781,10 @@ MatrixClient.prototype.loadRoomMembersIfNeeded = async function(roomId) {
if (!room || !room.needsOutOfBandMembers()) {
return;
}
// Note that we don't await _loadMembers here first.
// setLazyLoadedMembers sets a flag before it awaits the promise passed in
// to avoid a race when calling membersNeedLoading/loadOutOfBandMembers
// in fast succession, before the first promise resolves.
const membersPromise = this._loadMembers(room);
await room.loadOutOfBandMembers(membersPromise);
};