WIP
This commit is contained in:
parent
404de53c75
commit
01ff806b86
2 changed files with 22 additions and 4 deletions
|
@ -34,6 +34,19 @@ export class BrawlViewModel extends ViewModel {
|
||||||
|
|
||||||
this._sessionContainer = null;
|
this._sessionContainer = null;
|
||||||
this._sessionCallback = this._sessionCallback.bind(this);
|
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() {
|
async load() {
|
||||||
|
|
|
@ -25,10 +25,15 @@ export class URLRouter {
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
this._subscription = this._pathObservable.subscribe(url => {
|
this._subscription = this._pathObservable.subscribe(url => {
|
||||||
const segments = this._segmentsFromUrl(url);
|
this._applyUrl(url);
|
||||||
const path = this._navigation.pathFrom(segments);
|
|
||||||
this._navigation.applyPath(path);
|
|
||||||
});
|
});
|
||||||
|
this._applyUrl(this._pathObservable.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
_applyUrl(url) {
|
||||||
|
const segments = this._segmentsFromUrl(url);
|
||||||
|
const path = this._navigation.pathFrom(segments);
|
||||||
|
this._navigation.applyPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
|
@ -36,7 +41,7 @@ export class URLRouter {
|
||||||
}
|
}
|
||||||
|
|
||||||
_segmentsFromUrl(path) {
|
_segmentsFromUrl(path) {
|
||||||
const parts = path.split("/");
|
const parts = path.split("/").filter(p => !!p);
|
||||||
let index = 0;
|
let index = 0;
|
||||||
const segments = [];
|
const segments = [];
|
||||||
while (index < parts.length) {
|
while (index < parts.length) {
|
||||||
|
|
Reference in a new issue