Take the hiding code out of the root view model

This commit is contained in:
Danila Fedorin 2021-08-24 12:24:09 -07:00
parent bfcac9fafb
commit b17ce2ee13
2 changed files with 13 additions and 25 deletions

View file

@ -21,8 +21,7 @@ import {LoadServerPolicyView} from "./policy/LoadServerPolicyView.js";
export class RootView extends TemplateView { export class RootView extends TemplateView {
render(t, vm) { render(t, vm) {
return t.if(vm => !vm.hidden, return t.div({className: "RootView"}, [
vm => t.div({className: "RootView"}, [
t.mapView(vm => vm.openLinkViewModel, vm => vm ? new OpenLinkView(vm) : null), t.mapView(vm => vm.openLinkViewModel, vm => vm ? new OpenLinkView(vm) : null),
t.mapView(vm => vm.createLinkViewModel, vm => vm ? new CreateLinkView(vm) : null), t.mapView(vm => vm.createLinkViewModel, vm => vm ? new CreateLinkView(vm) : null),
t.mapView(vm => vm.loadServerPolicyViewModel, vm => vm ? new LoadServerPolicyView(vm) : null), t.mapView(vm => vm.loadServerPolicyViewModel, vm => vm ? new LoadServerPolicyView(vm) : null),
@ -36,8 +35,7 @@ export class RootView extends TemplateView {
t.button({className: "text", onClick: () => vm.clearPreferences()}, "Clear preferences")), t.button({className: "text", onClick: () => vm.clearPreferences()}, "Clear preferences")),
]) ])
]) ])
]) ]);
);
} }
} }

View file

@ -25,7 +25,6 @@ import {Platform} from "./Platform.js";
export class RootViewModel extends ViewModel { export class RootViewModel extends ViewModel {
constructor(options) { constructor(options) {
super(options); super(options);
this.hidden = false;
this.link = null; this.link = null;
this.openLinkViewModel = null; this.openLinkViewModel = null;
this.createLinkViewModel = null; this.createLinkViewModel = null;
@ -59,15 +58,6 @@ export class RootViewModel extends ViewModel {
} else { } else {
const oldLink = this.link; const oldLink = this.link;
this.link = Link.parse(hash); this.link = Link.parse(hash);
const matrixUrl = this.link.toMatrixUrl()
if (matrixUrl) {
this.hidden = true;
setTimeout(() => {
this.hidden = false;
this.emitChange();
}, 1000);
this.openLink(this.link.toMatrixUrl());
}
this._updateChildVMs(oldLink); this._updateChildVMs(oldLink);
} }
} }