From f5acee02be061c49eaee42405c518d66d612c800 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 20 Aug 2020 16:20:35 +0200 Subject: [PATCH] add comment why we do things in this order --- src/matrix/room/timeline/persistence/GapWriter.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/matrix/room/timeline/persistence/GapWriter.js b/src/matrix/room/timeline/persistence/GapWriter.js index 7a7ab4f5..834239f7 100644 --- a/src/matrix/room/timeline/persistence/GapWriter.js +++ b/src/matrix/room/timeline/persistence/GapWriter.js @@ -132,7 +132,10 @@ export class GapWriter { return RoomMember.fromMemberEvent(this._roomId, event)?.serialize(); } } - // look into newer events, but using prev_content if found + // look into newer events, but using prev_content if found. + // We do this before looking into `state` because it is not well specified + // in the spec whether the events in there represent state before or after `chunk`. + // So we look both directions first in chunk to make sure it doesn't matter. for (let i = index; i >= 0 && i < events.length; i -= inc) { const event = events[i]; if (isOurUser(event)) {