You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
store OOB status along with members, to avoid unneccesary fetching
for some small rooms, it is possible that calling /members would not yield any previously unknown members, as they were all recently active. This would be the case for most DMs. For these rooms, we'd end up with 0 OOB members after lazy loading them, so when getting them out of storage we need a way to distuinguist this case from never having lazy loaded the members of the room at all. We store a marker object in the same store and return [] or null accordingly. This way the /members don't get fetched a second time.
This commit is contained in:
@@ -762,7 +762,7 @@ MatrixClient.prototype._loadMembers = async function(room) {
|
||||
// were the members loaded from the server?
|
||||
let fromServer = false;
|
||||
let rawMembersEvents = await this.store.getOutOfBandMembers(roomId);
|
||||
if (rawMembersEvents.length == 0) {
|
||||
if (rawMembersEvents === null) {
|
||||
fromServer = true;
|
||||
const lastEventId = room.getLastEventId();
|
||||
const response = await this.members(roomId, "join", "leave", lastEventId);
|
||||
@@ -802,18 +802,8 @@ MatrixClient.prototype.loadRoomMembersIfNeeded = async function(roomId) {
|
||||
const rawMembersEvents = room.currentState.getMembers()
|
||||
.filter((m) => m.isOutOfBand())
|
||||
.map((m) => m.events.member.event);
|
||||
// TODO: probably need a way to mark a room as lazy loaded
|
||||
// even though we didn't store any members, as we'll just
|
||||
// lazy loaded the room in every session. This is a likely
|
||||
// scenario for DM's where all the members would likely
|
||||
// be known without lazy loading.
|
||||
if (rawMembersEvents.length) {
|
||||
console.log(`LL: telling backend to store ${rawMembersEvents.length} members`);
|
||||
await this.store.setOutOfBandMembers(roomId, rawMembersEvents);
|
||||
}
|
||||
else {
|
||||
console.log(`LL: no members needed to be stored`);
|
||||
}
|
||||
console.log(`LL: telling backend to store ${rawMembersEvents.length} members`);
|
||||
await this.store.setOutOfBandMembers(roomId, rawMembersEvents);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user