mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
also do redirect after initial navigation
This commit is contained in:
parent
1780f334ea
commit
7f3e0f237b
@ -38,7 +38,25 @@ export class RootViewModel extends ViewModel {
|
|||||||
async load() {
|
async load() {
|
||||||
this.track(this.navigation.observe("login").subscribe(() => this._applyNavigation()));
|
this.track(this.navigation.observe("login").subscribe(() => this._applyNavigation()));
|
||||||
this.track(this.navigation.observe("session").subscribe(() => this._applyNavigation()));
|
this.track(this.navigation.observe("session").subscribe(() => this._applyNavigation()));
|
||||||
if (!this._applyNavigation()) {
|
this._applyNavigation();
|
||||||
|
}
|
||||||
|
|
||||||
|
async _applyNavigation() {
|
||||||
|
const isLogin = this.navigation.observe("login").get();
|
||||||
|
const sessionId = this.navigation.observe("session").get();
|
||||||
|
if (isLogin) {
|
||||||
|
if (this.activeSection !== "login") {
|
||||||
|
this._showLogin();
|
||||||
|
}
|
||||||
|
} else if (sessionId === true) {
|
||||||
|
if (this.activeSection !== "picker") {
|
||||||
|
this._showPicker();
|
||||||
|
}
|
||||||
|
} else if (sessionId) {
|
||||||
|
if (!this._sessionViewModel || this._sessionViewModel.id !== sessionId) {
|
||||||
|
this._showSessionLoader(sessionId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
// redirect depending on what sessions are already present
|
// redirect depending on what sessions are already present
|
||||||
const sessionInfos = await this._sessionInfoStorage.getAll();
|
const sessionInfos = await this._sessionInfoStorage.getAll();
|
||||||
@ -51,22 +69,6 @@ export class RootViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_applyNavigation() {
|
|
||||||
const isLogin = this.navigation.observe("login").get();
|
|
||||||
const sessionId = this.navigation.observe("session").get();
|
|
||||||
if (isLogin) {
|
|
||||||
this._showLogin();
|
|
||||||
return true;
|
|
||||||
} else if (sessionId === true) {
|
|
||||||
this._showPicker();
|
|
||||||
return true;
|
|
||||||
} else if (sessionId) {
|
|
||||||
this._showSessionLoader(sessionId);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_urlForSessionInfos(sessionInfos) {
|
_urlForSessionInfos(sessionInfos) {
|
||||||
if (sessionInfos.length === 0) {
|
if (sessionInfos.length === 0) {
|
||||||
return this.urlRouter.urlForSegment("login");
|
return this.urlRouter.urlForSegment("login");
|
||||||
|
@ -61,6 +61,10 @@ export class SessionViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get id() {
|
||||||
|
return this._sessionContainer.sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
this._sessionStatusViewModel.start();
|
this._sessionStatusViewModel.start();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user