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(); super();
this._roomVM = roomVM; this._roomVM = roomVM;
this._isEmpty = true; this._isEmpty = true;
this._replyId = null;
this._replyVM = null; this._replyVM = null;
} }
setReplyingTo(tile) { setReplyingTo(entry) {
const changed = this._replyVM !== tile; const newId = entry?.id || null;
this._replyVM = tile; const changed = this._replyId !== newId;
if (changed) { 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"); this.emitChange("replyViewModel");
} }
} }

View File

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

View File

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