diff --git a/src/domain/session/room/timeline/TilesCollection.js b/src/domain/session/room/timeline/TilesCollection.js index 69268b41..818bfba3 100644 --- a/src/domain/session/room/timeline/TilesCollection.js +++ b/src/domain/session/room/timeline/TilesCollection.js @@ -95,8 +95,14 @@ export default class TilesCollection extends BaseObservableList { const newTile = this._tileCreator(entry, this._emitSpontanousUpdate); if (newTile) { - prevTile && prevTile.updateNextSibling(newTile); - nextTile && nextTile.updatePreviousSibling(newTile); + if (prevTile) { + prevTile.updateNextSibling(newTile); + newTile.updatePreviousSibling(prevTile); + } + if (nextTile) { + newTile.updateNextSibling(nextTile); + nextTile.updatePreviousSibling(newTile); + } this._tiles.splice(tileIdx, 0, newTile); this.emitAdd(tileIdx, newTile); } diff --git a/src/domain/session/room/timeline/tiles/MessageTile.js b/src/domain/session/room/timeline/tiles/MessageTile.js index 80ea8ebb..deff0c77 100644 --- a/src/domain/session/room/timeline/tiles/MessageTile.js +++ b/src/domain/session/room/timeline/tiles/MessageTile.js @@ -6,6 +6,7 @@ export default class MessageTile extends SimpleTile { super(options); this._isOwn = this._entry.event.sender === options.ownUserId; this._date = new Date(this._entry.event.origin_server_ts); + this._isContinuation = false; } get shape() { @@ -28,8 +29,21 @@ export default class MessageTile extends SimpleTile { return this._isOwn; } + get isContinuation() { + return this._isContinuation; + } + _getContent() { const event = this._entry.event; return event && event.content; } + + updatePreviousSibling(prev) { + super.updatePreviousSibling(prev); + const isContinuation = prev && prev instanceof MessageTile && prev.sender === this.sender; + if (isContinuation !== this._isContinuation) { + this._isContinuation = isContinuation; + this.emitUpdate("isContinuation"); + } + } } diff --git a/src/ui/web/general/ListView.js b/src/ui/web/general/ListView.js index 1b305228..bab72006 100644 --- a/src/ui/web/general/ListView.js +++ b/src/ui/web/general/ListView.js @@ -125,7 +125,10 @@ export default class ListView { } onUpdate(i, value, params) { - this._childInstances[i].update(value, params); + if (this._childInstances) { + const instance = this._childInstances[i]; + instance && instance.update(value, params); + } } onBeforeListChanged() {} diff --git a/src/ui/web/session/room/timeline/TextMessageView.js b/src/ui/web/session/room/timeline/TextMessageView.js index 31c3d103..25a7003f 100644 --- a/src/ui/web/session/room/timeline/TextMessageView.js +++ b/src/ui/web/session/room/timeline/TextMessageView.js @@ -6,7 +6,7 @@ export default class TextMessageView extends TemplateView { return t.li( {className: {"TextMessageView": true, own: vm.isOwn}}, t.div({className: "message-container"}, [ - t.div({className: "sender"}, vm.sender), + t.div({className: "sender"}, vm => vm.isContinuation ? "" : vm.sender), t.p([vm.text, t.time(vm.time)]), ]) );