From 1f139f17e99153c36affea9acc548ecf7fe21a1c Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Fri, 26 Aug 2022 14:43:41 +0530 Subject: [PATCH] Add explaining comments --- src/domain/ForcedLogoutViewModel.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/domain/ForcedLogoutViewModel.ts b/src/domain/ForcedLogoutViewModel.ts index 5b7f84ef..0659f803 100644 --- a/src/domain/ForcedLogoutViewModel.ts +++ b/src/domain/ForcedLogoutViewModel.ts @@ -30,6 +30,7 @@ export class ForcedLogoutViewModel extends ViewModel { constructor(options: Options) { super(options); this._sessionId = options.sessionId; + // Start the logout process immediately without any user interaction this._logoutPromise = this.forceLogout(); } @@ -40,6 +41,7 @@ export class ForcedLogoutViewModel extends ViewModel { } catch (err) { this._error = err; + // Show the error in the UI this._showSpinner = false; this._showStatus = true; this.emitChange("error"); @@ -47,10 +49,15 @@ export class ForcedLogoutViewModel extends ViewModel { } async proceed(): Promise { + /** + * The logout should already be completed because we started it from the ctor. + * In case the logout is still proceeding, we will show a message with a spinner. + */ this._showSpinner = true; this._showStatus = true; this.emitChange("showStatus"); await this._logoutPromise; + // At this point, the logout is completed for sure. if (!this._error) { this.navigation.push("session", true); }