From ee0effdab812d22e17beb9a6e2bad2cf0f709fe7 Mon Sep 17 00:00:00 2001 From: Midhun Suresh <midhunr@element.io> Date: Fri, 14 Jan 2022 13:33:11 +0530 Subject: [PATCH] Fix navigation --- src/viewmodels/AccountSetupViewModel.ts | 4 ++++ src/viewmodels/RootViewModel.ts | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/viewmodels/AccountSetupViewModel.ts b/src/viewmodels/AccountSetupViewModel.ts index 91c0c7b..5791a7d 100644 --- a/src/viewmodels/AccountSetupViewModel.ts +++ b/src/viewmodels/AccountSetupViewModel.ts @@ -57,6 +57,10 @@ export class AccountSetupViewModel extends ViewModel { this._state.set("timeline"); } + dismiss() { + this._state.set("start"); + } + private get _homeserver(): string { return this._config.homeserver; } diff --git a/src/viewmodels/RootViewModel.ts b/src/viewmodels/RootViewModel.ts index ef4e184..3a54abc 100644 --- a/src/viewmodels/RootViewModel.ts +++ b/src/viewmodels/RootViewModel.ts @@ -18,16 +18,16 @@ export class RootViewModel extends ViewModel { super(options); this._config = config; this._client = new Client(this.platform); + this._state.subscribe(stage => this._applyNavigation(stage)); } async start() { - this._state.subscribe(stage => this._applyNavigation(stage)); const sessionAlreadyExists = await this.attemptStartWithExistingSession(); if (sessionAlreadyExists) { - this._showTimeline(); + this._state.set("timeline"); return; } - this._showAccountSetup(); + this._state.set("account-setup"); } private _applyNavigation(stage: string) { @@ -35,6 +35,12 @@ export class RootViewModel extends ViewModel { case "timeline": this._showTimeline(); break; + case "start": + this._showStartButton(); + break; + case "account-setup": + this._showAccountSetup(); + break; } } @@ -57,6 +63,11 @@ export class RootViewModel extends ViewModel { this.emitChange("activeSection"); } + private _showStartButton() { + this._activeSection = "start"; + this.emitChange("activeSection"); + } + /** * Try to start Hydrogen based on an existing hydrogen session. * If multiple sessions exist, this method chooses the most recent one. -- GitLab