mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
WIP
This commit is contained in:
parent
404de53c75
commit
01ff806b86
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user