mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
Add _replyTo field to ComposerViewModel that can be set from a message
This commit is contained in:
parent
13932bb480
commit
fdcafaf6d3
@ -44,6 +44,7 @@ export class RoomViewModel extends ViewModel {
|
|||||||
const timeline = await this._room.openTimeline();
|
const timeline = await this._room.openTimeline();
|
||||||
const timelineVM = this.track(new TimelineViewModel(this.childOptions({
|
const timelineVM = this.track(new TimelineViewModel(this.childOptions({
|
||||||
room: this._room,
|
room: this._room,
|
||||||
|
roomVM: this,
|
||||||
timeline,
|
timeline,
|
||||||
})));
|
})));
|
||||||
this._timelineVM = timelineVM;
|
this._timelineVM = timelineVM;
|
||||||
@ -294,12 +295,17 @@ export class RoomViewModel extends ViewModel {
|
|||||||
path = path.with(this.navigation.segment("details", true));
|
path = path.with(this.navigation.segment("details", true));
|
||||||
this.navigation.applyPath(path);
|
this.navigation.applyPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setReply(entry) {
|
||||||
|
this._composerVM.setReply(entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ComposerViewModel extends ViewModel {
|
class ComposerViewModel extends ViewModel {
|
||||||
constructor(roomVM) {
|
constructor(roomVM) {
|
||||||
super();
|
super();
|
||||||
this._roomVM = roomVM;
|
this._roomVM = roomVM;
|
||||||
|
this._replyTo = null;
|
||||||
this._isEmpty = true;
|
this._isEmpty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,6 +313,19 @@ class ComposerViewModel extends ViewModel {
|
|||||||
return this._roomVM.isEncrypted;
|
return this._roomVM.isEncrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setReply(entry) {
|
||||||
|
this._replyTo = entry;
|
||||||
|
this.emitChange("replyTo");
|
||||||
|
}
|
||||||
|
|
||||||
|
clearReply() {
|
||||||
|
this.setReply(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
get replyTo() {
|
||||||
|
return this._replyTo;
|
||||||
|
}
|
||||||
|
|
||||||
sendMessage(message) {
|
sendMessage(message) {
|
||||||
const success = this._roomVM._sendMessage(message);
|
const success = this._roomVM._sendMessage(message);
|
||||||
if (success) {
|
if (success) {
|
||||||
|
@ -38,9 +38,9 @@ import {ViewModel} from "../../../ViewModel.js";
|
|||||||
export class TimelineViewModel extends ViewModel {
|
export class TimelineViewModel extends ViewModel {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
const {room, timeline} = options;
|
const {room, timeline, roomVM} = options;
|
||||||
this._timeline = this.track(timeline);
|
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})));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,6 +106,10 @@ export class BaseMessageTile extends SimpleTile {
|
|||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setReply() {
|
||||||
|
this._roomVM.setReply(this._entry);
|
||||||
|
}
|
||||||
|
|
||||||
redact(reason, log) {
|
redact(reason, log) {
|
||||||
return this._room.sendRedaction(this._entry.id, reason, log);
|
return this._room.sendRedaction(this._entry.id, reason, log);
|
||||||
}
|
}
|
||||||
|
@ -129,6 +129,10 @@ export class SimpleTile extends ViewModel {
|
|||||||
return this._options.room;
|
return this._options.room;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get _roomVM() {
|
||||||
|
return this._options.roomVM;
|
||||||
|
}
|
||||||
|
|
||||||
get _timeline() {
|
get _timeline() {
|
||||||
return this._options.timeline;
|
return this._options.timeline;
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,7 @@ export class BaseMessageView extends TemplateView {
|
|||||||
if (vm.canReact && vm.shape !== "redacted") {
|
if (vm.canReact && vm.shape !== "redacted") {
|
||||||
options.push(new QuickReactionsMenuOption(vm));
|
options.push(new QuickReactionsMenuOption(vm));
|
||||||
}
|
}
|
||||||
|
options.push(Menu.option(vm.i18n`Reply`, () => vm.setReply()));
|
||||||
if (vm.canAbortSending) {
|
if (vm.canAbortSending) {
|
||||||
options.push(Menu.option(vm.i18n`Cancel`, () => vm.abortSending()));
|
options.push(Menu.option(vm.i18n`Cancel`, () => vm.abortSending()));
|
||||||
} else if (vm.canRedact) {
|
} else if (vm.canRedact) {
|
||||||
|
Loading…
Reference in New Issue
Block a user