From 90d0fd1f89fd7e87e4897ea35edd1867a89b3978 Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Sat, 25 Jun 2022 12:48:14 +0200 Subject: [PATCH] also always update siblings when adding an entry,even when there is none otherwise the first item in the list won't have a date separator --- .../session/room/timeline/TilesCollection.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/domain/session/room/timeline/TilesCollection.js b/src/domain/session/room/timeline/TilesCollection.js index 173b0cf6..0dad903f 100644 --- a/src/domain/session/room/timeline/TilesCollection.js +++ b/src/domain/session/room/timeline/TilesCollection.js @@ -130,15 +130,11 @@ export class TilesCollection extends BaseObservableList { const newTile = this._createTile(entry); if (newTile) { - if (prevTile) { - prevTile.updateNextSibling(newTile); - // this emits an update while the add hasn't been emitted yet - newTile.updatePreviousSibling(prevTile); - } - if (nextTile) { - newTile.updateNextSibling(nextTile); - nextTile.updatePreviousSibling(newTile); - } + prevTile?.updateNextSibling(newTile); + // this emits an update while the add hasn't been emitted yet + newTile.updatePreviousSibling(prevTile); + newTile.updateNextSibling(nextTile); + nextTile?.updatePreviousSibling(newTile); this._tiles.splice(tileIdx, 0, newTile); this.emitAdd(tileIdx, newTile); // add event is emitted, now the tile