This commit is contained in:
Bruno Windels 2020-10-07 09:40:51 +02:00
parent 404de53c75
commit 01ff806b86
2 changed files with 22 additions and 4 deletions

View file

@ -34,6 +34,19 @@ export class BrawlViewModel extends ViewModel {
this._sessionContainer = null;
this._sessionCallback = this._sessionCallback.bind(this);
this.track(this.navigation.observe("login").subscribe(value => {
if (value) {
this._showLogin();
}
}));
this.track(this.navigation.observe("session").subscribe(value => {
if (value === true) {
this._showPicker();
} else if (value) {
alert("showing session " + value);
}
}));
}
async load() {

View file

@ -25,10 +25,15 @@ export class URLRouter {
start() {
this._subscription = this._pathObservable.subscribe(url => {
this._applyUrl(url);
});
this._applyUrl(this._pathObservable.get());
}
_applyUrl(url) {
const segments = this._segmentsFromUrl(url);
const path = this._navigation.pathFrom(segments);
this._navigation.applyPath(path);
});
}
stop() {
@ -36,7 +41,7 @@ export class URLRouter {
}
_segmentsFromUrl(path) {
const parts = path.split("/");
const parts = path.split("/").filter(p => !!p);
let index = 0;
const segments = [];
while (index < parts.length) {