From cb0ab589de1d411f24006cce65fd0e3ecdada1c2 Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Fri, 25 Nov 2022 11:51:38 +0100 Subject: [PATCH] remove lower bound check as we don't go negative anymore --- src/domain/session/room/timeline/TilesCollection.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/domain/session/room/timeline/TilesCollection.js b/src/domain/session/room/timeline/TilesCollection.js index 6652e89c..c9a9d6df 100644 --- a/src/domain/session/room/timeline/TilesCollection.js +++ b/src/domain/session/room/timeline/TilesCollection.js @@ -157,9 +157,6 @@ export class TilesCollection extends BaseObservableList { // next next tile for (let i = 0; i < 2; i += 1) { const idx = tileIdx + i; - if (idx < 0) { - continue; - } if (idx >= this._tiles.length) { break; } @@ -167,11 +164,11 @@ export class TilesCollection extends BaseObservableList { const prevTile = idx > 0 ? this._tiles[idx - 1] : undefined; const hasDateSeparator = prevTile?.shape === TileShape.DateHeader; if (tile.needsDateSeparator && !hasDateSeparator) { - // adding a tile shift all the indices we need to consider - // especially given we consider removals for the tile that - // comes after a datetile - tileIdx += 1; - this._addTileAt(idx, tile.createDateSeparator()); + // adding a tile shift all the indices we need to consider + // especially given we consider removals for the tile that + // comes after a datetile + tileIdx += 1; + this._addTileAt(idx, tile.createDateSeparator()); } else if (!tile.needsDateSeparator && hasDateSeparator) { // this is never triggered because needsDateSeparator is not cleared // when loading more items because we don't do anything once the