diff --git a/src/domain/BrawlViewModel.js b/src/domain/BrawlViewModel.js index 4c3a97bb..2ff1abae 100644 --- a/src/domain/BrawlViewModel.js +++ b/src/domain/BrawlViewModel.js @@ -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() { diff --git a/src/domain/navigation/URLRouter.js b/src/domain/navigation/URLRouter.js index 5dcd9944..c82b814b 100644 --- a/src/domain/navigation/URLRouter.js +++ b/src/domain/navigation/URLRouter.js @@ -25,10 +25,15 @@ export class URLRouter { start() { this._subscription = this._pathObservable.subscribe(url => { - const segments = this._segmentsFromUrl(url); - const path = this._navigation.pathFrom(segments); - this._navigation.applyPath(path); + 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) {