forked from mystiq/hydrogen-web
Merge branch 'replies' of github.com:vector-im/hydrogen-web into replies
This commit is contained in:
commit
f8dae8e20c
1 changed files with 20 additions and 11 deletions
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
import {ViewModel} from "../../ViewModel.js";
|
import {ViewModel} from "../../ViewModel.js";
|
||||||
|
|
||||||
export class ComposerViewModel extends ViewModel {
|
export class ComposerViewModel extends ViewModel {
|
||||||
|
@ -5,22 +21,15 @@ 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(entry) {
|
setReplyingTo(entry) {
|
||||||
const newId = entry?.id || null;
|
const changed = this._replyVM?.internalId !== entry?.asEventKey().toString();
|
||||||
const changed = this._replyId !== newId;
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
this._replyId = newId;
|
this._replyVM = this.disposeTracked(this._replyVM);
|
||||||
if (this._replyVM) {
|
if (entry) {
|
||||||
this.untrack(this._replyVM);
|
this._replyVM = this.track(this._roomVM._createTile(entry));
|
||||||
this._replyVM.dispose();
|
|
||||||
}
|
|
||||||
this._replyVM = entry && this._roomVM._createTile(entry);
|
|
||||||
if (this._replyVM) {
|
|
||||||
this.track(this._replyVM);
|
|
||||||
}
|
}
|
||||||
this.emitChange("replyViewModel");
|
this.emitChange("replyViewModel");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue