1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

prototype support for lazily loading members in matrixclient

This commit is contained in:
Bruno Windels
2018-07-10 17:17:27 +02:00
parent 2b5925b893
commit 2c5cad71ee
3 changed files with 44 additions and 0 deletions

View File

@@ -757,6 +757,20 @@ MatrixClient.prototype.getRoom = function(roomId) {
return this.store.getRoom(roomId);
};
/**
* Preloads the member list for the given room id,
* in case lazy loading of memberships is in use.
* @param {string} roomId The room ID
*/
MatrixClient.prototype.loadRoomMembersIfNeeded = function(roomId) {
const room = this.getRoom(roomId);
if (!room || !room.membersNeedLoading()) {
return;
}
const membersPromise = this.joinedMembers(roomId);
room.setLazilyLoadedMembers(membersPromise);
}
/**
* Retrieve all known rooms.
* @return {Room[]} A list of rooms, or an empty list if there is no data store.