Create new tiles instead of keeping old ones

This commit is contained in:
Danila Fedorin 2021-08-05 10:05:50 -07:00
parent 434882069e
commit 21b067eaff
3 changed files with 18 additions and 4 deletions

View file

@ -5,13 +5,23 @@ export class ComposerViewModel extends ViewModel {
super();
this._roomVM = roomVM;
this._isEmpty = true;
this._replyId = null;
this._replyVM = null;
}
setReplyingTo(tile) {
const changed = this._replyVM !== tile;
this._replyVM = tile;
setReplyingTo(entry) {
const newId = entry?.id || null;
const changed = this._replyId !== newId;
if (changed) {
this._replyId = newId;
if (this._replyVM) {
this.untrack(this._replyVM);
this._replyVM.dispose();
}
this._replyVM = entry && this._roomVM._createTile(entry);
if (this._replyVM) {
this.track(this._replyVM);
}
this.emitChange("replyViewModel");
}
}

View file

@ -161,6 +161,10 @@ export class RoomViewModel extends ViewModel {
this._room.join();
}
_createTile(entry) {
return this._tilesCreator(entry);
}
async _sendMessage(message, replyingTo) {
if (!this._room.isArchived && message) {
try {

View file

@ -107,7 +107,7 @@ export class BaseMessageTile extends SimpleTile {
}
startReply() {
this._roomVM.startReply(this);
this._roomVM.startReply(this._entry);
}
reply(msgtype, body, log = null) {