From 6f37c232f7023c7f2922225ed7f93a1af1dd2bac Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 8 Apr 2021 12:56:24 +0200 Subject: [PATCH] Don't cache members that haven't been written yet - fixes #271 --- src/matrix/room/timeline/persistence/MemberWriter.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/matrix/room/timeline/persistence/MemberWriter.js b/src/matrix/room/timeline/persistence/MemberWriter.js index 9143acc9..dc6f621d 100644 --- a/src/matrix/room/timeline/persistence/MemberWriter.js +++ b/src/matrix/room/timeline/persistence/MemberWriter.js @@ -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; @@ -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); + }, }; }