From 56495c9d13da069332db0743fb17fc3a18f79fb3 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 27 May 2021 09:10:10 +0200 Subject: [PATCH] fix gap failing to fill 2nd time + unit regression test --- .../session/room/timeline/tiles/GapTile.js | 28 +++++++++++++++++++ .../session/room/timeline/tiles/SimpleTile.js | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/domain/session/room/timeline/tiles/GapTile.js b/src/domain/session/room/timeline/tiles/GapTile.js index 1b05c1c8..dbf5cf63 100644 --- a/src/domain/session/room/timeline/tiles/GapTile.js +++ b/src/domain/session/room/timeline/tiles/GapTile.js @@ -72,3 +72,31 @@ export class GapTile extends SimpleTile { return null; } } + +import {FragmentBoundaryEntry} from "../../../../../matrix/room/timeline/entries/FragmentBoundaryEntry.js"; +export function tests() { + return { + "uses updated token to fill": async assert => { + let currentToken = 5; + const fragment = { + id: 0, + previousToken: currentToken, + roomId: "!abc" + }; + const room = { + async fillGap(entry) { + console.log(entry.token, currentToken); + assert.equal(entry.token, currentToken); + currentToken += 1; + const newEntry = entry.withUpdatedFragment(Object.assign({}, fragment, {previousToken: currentToken})); + tile.updateEntry(newEntry); + } + }; + const tile = new GapTile({entry: new FragmentBoundaryEntry(fragment, true), room}); + await tile.fill(); + await tile.fill(); + await tile.fill(); + assert.equal(currentToken, 8); + } + } +} \ No newline at end of file diff --git a/src/domain/session/room/timeline/tiles/SimpleTile.js b/src/domain/session/room/timeline/tiles/SimpleTile.js index 29f9980b..07529b51 100644 --- a/src/domain/session/room/timeline/tiles/SimpleTile.js +++ b/src/domain/session/room/timeline/tiles/SimpleTile.js @@ -85,7 +85,7 @@ export class SimpleTile extends ViewModel { // update received for already included (falls within sort keys) entry updateEntry(entry, param) { const renderedAsRedacted = this.shape === "redacted"; - if (entry.isRedacted !== renderedAsRedacted) { + if (!entry.isGap && entry.isRedacted !== renderedAsRedacted) { // recreate the tile if the entry becomes redacted return UpdateAction.Replace("shape"); } else {