diff --git a/src/domain/session/room/RoomViewModel.js b/src/domain/session/room/RoomViewModel.js index 3b04f83a..0bd56f8e 100644 --- a/src/domain/session/room/RoomViewModel.js +++ b/src/domain/session/room/RoomViewModel.js @@ -44,6 +44,7 @@ export class RoomViewModel extends ViewModel { const timeline = await this._room.openTimeline(); const timelineVM = this.track(new TimelineViewModel(this.childOptions({ room: this._room, + roomVM: this, timeline, }))); this._timelineVM = timelineVM; @@ -294,12 +295,17 @@ export class RoomViewModel extends ViewModel { path = path.with(this.navigation.segment("details", true)); this.navigation.applyPath(path); } + + setReply(entry) { + this._composerVM.setReply(entry); + } } class ComposerViewModel extends ViewModel { constructor(roomVM) { super(); this._roomVM = roomVM; + this._replyTo = null; this._isEmpty = true; } @@ -307,6 +313,19 @@ class ComposerViewModel extends ViewModel { return this._roomVM.isEncrypted; } + setReply(entry) { + this._replyTo = entry; + this.emitChange("replyTo"); + } + + clearReply() { + this.setReply(null); + } + + get replyTo() { + return this._replyTo; + } + sendMessage(message) { const success = this._roomVM._sendMessage(message); if (success) { diff --git a/src/domain/session/room/timeline/TimelineViewModel.js b/src/domain/session/room/timeline/TimelineViewModel.js index d91b9acb..5ec21d9a 100644 --- a/src/domain/session/room/timeline/TimelineViewModel.js +++ b/src/domain/session/room/timeline/TimelineViewModel.js @@ -38,9 +38,9 @@ import {ViewModel} from "../../../ViewModel.js"; export class TimelineViewModel extends ViewModel { constructor(options) { super(options); - const {room, timeline} = options; + const {room, timeline, roomVM} = options; this._timeline = this.track(timeline); - this._tiles = new TilesCollection(timeline.entries, tilesCreator(this.childOptions({room, timeline}))); + this._tiles = new TilesCollection(timeline.entries, tilesCreator(this.childOptions({room, timeline, roomVM}))); } /** diff --git a/src/domain/session/room/timeline/tiles/BaseMessageTile.js b/src/domain/session/room/timeline/tiles/BaseMessageTile.js index 71c709b8..7090c514 100644 --- a/src/domain/session/room/timeline/tiles/BaseMessageTile.js +++ b/src/domain/session/room/timeline/tiles/BaseMessageTile.js @@ -106,6 +106,10 @@ export class BaseMessageTile extends SimpleTile { return action; } + setReply() { + this._roomVM.setReply(this._entry); + } + redact(reason, log) { return this._room.sendRedaction(this._entry.id, reason, log); } diff --git a/src/domain/session/room/timeline/tiles/SimpleTile.js b/src/domain/session/room/timeline/tiles/SimpleTile.js index 6ec913c0..efaa0a6a 100644 --- a/src/domain/session/room/timeline/tiles/SimpleTile.js +++ b/src/domain/session/room/timeline/tiles/SimpleTile.js @@ -129,6 +129,10 @@ export class SimpleTile extends ViewModel { return this._options.room; } + get _roomVM() { + return this._options.roomVM; + } + get _timeline() { return this._options.timeline; } diff --git a/src/platform/web/ui/session/room/timeline/BaseMessageView.js b/src/platform/web/ui/session/room/timeline/BaseMessageView.js index c5d860f2..c91a5ed7 100644 --- a/src/platform/web/ui/session/room/timeline/BaseMessageView.js +++ b/src/platform/web/ui/session/room/timeline/BaseMessageView.js @@ -113,6 +113,7 @@ export class BaseMessageView extends TemplateView { if (vm.canReact && vm.shape !== "redacted") { options.push(new QuickReactionsMenuOption(vm)); } + options.push(Menu.option(vm.i18n`Reply`, () => vm.setReply())); if (vm.canAbortSending) { options.push(Menu.option(vm.i18n`Cancel`, () => vm.abortSending())); } else if (vm.canRedact) {