Skip to content

Commit

Permalink
Don't cache members that haven't been written yet - fixes #271
Browse files Browse the repository at this point in the history
  • Loading branch information
bwindels committed Apr 8, 2021
1 parent f5db6ba commit 6f37c23
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/matrix/room/timeline/persistence/MemberWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ export class MemberWriter {
});
if (memberEvent) {
member = RoomMember.fromMemberEvent(this._roomId, memberEvent);
// adding it to the cache, but not storing it for now;
// we'll do that when we get to the event
this._cache.set(member);
}
}
return member;
Expand Down Expand Up @@ -222,5 +219,14 @@ export function tests() {
assert.equal(change.member.membership, "join");
assert.equal(txn.members.get(alice).displayName, "Alice");
},
"newly joined member causes a change with lookup done first": async assert => {
const event = createMemberEvent("join", alice, "Alice");
const writer = new MemberWriter(roomId);
const txn = createStorage();
const member = await writer.lookupSenderMember(event, [event], txn);
assert(member);
const change = await writer.writeTimelineMemberEvent(event, txn);
assert(change);
},
};
}

0 comments on commit 6f37c23

Please sign in to comment.