From 77dca5dd558f3a6e80684daadd7e09f3371711e3 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 27 Oct 2020 16:19:36 +0100 Subject: [PATCH] add update parameter when replacing tile --- src/domain/session/room/timeline/TilesCollection.js | 7 ++++--- src/domain/session/room/timeline/UpdateAction.js | 4 ++-- .../session/room/timeline/tiles/EncryptedEventTile.js | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/domain/session/room/timeline/TilesCollection.js b/src/domain/session/room/timeline/TilesCollection.js index 57eb75f0..2a53c9d4 100644 --- a/src/domain/session/room/timeline/TilesCollection.js +++ b/src/domain/session/room/timeline/TilesCollection.js @@ -150,7 +150,8 @@ export class TilesCollection extends BaseObservableList { if (action.shouldReplace) { const newTile = this._tileCreator(entry); if (newTile) { - this._replaceTile(tileIdx, tile, newTile); + this._replaceTile(tileIdx, tile, newTile, action.updateParams); + newTile.setUpdateEmit(this._emitSpontanousUpdate); } else { this._removeTile(tileIdx, tile); } @@ -175,7 +176,7 @@ export class TilesCollection extends BaseObservableList { // merge with neighbours? ... hard to imagine use case for this ... } - _replaceTile(tileIdx, existingTile, newTile) { + _replaceTile(tileIdx, existingTile, newTile, updateParams) { existingTile.dispose(); const prevTile = this._getTileAtIdx(tileIdx - 1); const nextTile = this._getTileAtIdx(tileIdx + 1); @@ -184,7 +185,7 @@ export class TilesCollection extends BaseObservableList { newTile.updatePreviousSibling(prevTile); newTile.updateNextSibling(nextTile); nextTile?.updatePreviousSibling(newTile); - this.emitUpdate(tileIdx, newTile, null); + this.emitUpdate(tileIdx, newTile, updateParams); } _removeTile(tileIdx, tile) { diff --git a/src/domain/session/room/timeline/UpdateAction.js b/src/domain/session/room/timeline/UpdateAction.js index 33a5dbe6..0bd90d7c 100644 --- a/src/domain/session/room/timeline/UpdateAction.js +++ b/src/domain/session/room/timeline/UpdateAction.js @@ -50,7 +50,7 @@ export class UpdateAction { return new UpdateAction(false, false, false, null); } - static Replace() { - return new UpdateAction(false, false, true, null); + static Replace(params) { + return new UpdateAction(false, false, true, params); } } diff --git a/src/domain/session/room/timeline/tiles/EncryptedEventTile.js b/src/domain/session/room/timeline/tiles/EncryptedEventTile.js index bc4f8feb..d4dbb632 100644 --- a/src/domain/session/room/timeline/tiles/EncryptedEventTile.js +++ b/src/domain/session/room/timeline/tiles/EncryptedEventTile.js @@ -22,7 +22,8 @@ export class EncryptedEventTile extends MessageTile { const parentResult = super.updateEntry(entry, params); // event got decrypted, recreate the tile and replace this one with it if (entry.eventType !== "m.room.encrypted") { - return UpdateAction.Replace(); + // the "shape" parameter trigger tile recreation in TimelineList + return UpdateAction.Replace("shape"); } else { return parentResult; }