Start work on handling invalid URLs
This commit is contained in:
parent
88116bdfa6
commit
878663ca07
@ -36,19 +36,12 @@ export class RootViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_updateChildVMs(oldLink) {
|
_updateChildVMs(oldLink) {
|
||||||
if (this.link) {
|
if (!oldLink || !oldLink.equals(this.link)) {
|
||||||
this.createLinkViewModel = null;
|
this.openLinkViewModel = new OpenLinkViewModel(this.childOptions({
|
||||||
if (!oldLink || !oldLink.equals(this.link)) {
|
link: this.link,
|
||||||
this.openLinkViewModel = new OpenLinkViewModel(this.childOptions({
|
clients: createClients(),
|
||||||
link: this.link,
|
}));
|
||||||
clients: createClients(),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.openLinkViewModel = null;
|
|
||||||
this.createLinkViewModel = new CreateLinkViewModel(this.childOptions());
|
|
||||||
}
|
}
|
||||||
this.emitChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_hideLinks() {
|
_hideLinks() {
|
||||||
@ -58,24 +51,30 @@ export class RootViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateHash(hash) {
|
updateHash(hash) {
|
||||||
|
// All view models except openLink are re-created anyway.
|
||||||
|
// Might as well clear them to avoid having to
|
||||||
|
// manually reset (n-1)/n view models in every case.
|
||||||
|
const oldLink = this.link;
|
||||||
|
this.link = null;
|
||||||
this.showDisclaimer = false;
|
this.showDisclaimer = false;
|
||||||
|
this.loadServerPolicyViewModel = null;
|
||||||
|
this.createLinkViewModel = null;
|
||||||
if (hash.startsWith("#/policy/")) {
|
if (hash.startsWith("#/policy/")) {
|
||||||
const server = hash.substr(9);
|
const server = hash.substr(9);
|
||||||
this._hideLinks();
|
this.openLinkViewModel = null;
|
||||||
this.loadServerPolicyViewModel = new LoadServerPolicyViewModel(this.childOptions({server}));
|
this.loadServerPolicyViewModel = new LoadServerPolicyViewModel(this.childOptions({server}));
|
||||||
this.loadServerPolicyViewModel.load();
|
this.loadServerPolicyViewModel.load();
|
||||||
this.emitChange();
|
|
||||||
} else if (hash.startsWith("#/disclaimer/")) {
|
} else if (hash.startsWith("#/disclaimer/")) {
|
||||||
this._hideLinks();
|
this.openLinkViewModel = null;
|
||||||
this.loadServerPolicyViewModel = null;
|
|
||||||
this.showDisclaimer = true;
|
this.showDisclaimer = true;
|
||||||
this.emitChange();
|
} else if (hash === "" || hash === "#" || hash === "#/") {
|
||||||
} else {
|
this.openLinkViewModel = null;
|
||||||
const oldLink = this.link;
|
this.createLinkViewModel = new CreateLinkViewModel(this.childOptions());
|
||||||
this.loadServerPolicyViewModel = null;
|
} else if (this.link = Link.parse(hash)) {
|
||||||
this.link = Link.parse(hash);
|
this.link = Link.parse(hash);
|
||||||
this._updateChildVMs(oldLink);
|
this._updateChildVMs(oldLink);
|
||||||
}
|
}
|
||||||
|
this.emitChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
clearPreferences() {
|
clearPreferences() {
|
||||||
|
Loading…
Reference in New Issue
Block a user