From 69478b81b2c45689d7e16d794801d32ddace6e64 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 23 Aug 2021 15:48:29 +0530 Subject: [PATCH] Fix toggleBusy Signed-off-by: RMidhunSuresh --- src/domain/login/LoginViewModel.js | 14 ++++++-------- src/domain/login/PasswordLoginViewModel.js | 4 ++-- src/domain/login/StartSSOLoginViewModel.js | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/domain/login/LoginViewModel.js b/src/domain/login/LoginViewModel.js index 13087581..97534a56 100644 --- a/src/domain/login/LoginViewModel.js +++ b/src/domain/login/LoginViewModel.js @@ -116,22 +116,20 @@ export class LoginViewModel extends ViewModel { this.emitChange("errorMessage"); } - _toggleBusy(status) { - this._isBusy = status; + _toggleBusy() { + this._isBusy = !this._isBusy; + this._passwordLoginViewModel?.toggleBusy(); + this._startSSOLoginViewModel?.toggleBusy(); this.emitChange("isBusy"); } async attemptLogin(loginMethod) { - this._toggleBusy(true); - this._passwordLoginViewModel?.toggleBusy(true); - this._startSSOLoginViewModel?.toggleBusy(true); + this._toggleBusy(); this._sessionContainer.startWithLogin(loginMethod); const loadStatus = this._sessionContainer.loadStatus; const handle = loadStatus.waitFor(status => status !== LoadStatus.Login); await handle.promise; - this._toggleBusy(false); - this._passwordLoginViewModel?.toggleBusy(false); - this._startSSOLoginViewModel?.toggleBusy(false); + this._toggleBusy(); const status = loadStatus.get(); if (status === LoadStatus.LoginFailed) { return this._sessionContainer.loginFailure; diff --git a/src/domain/login/PasswordLoginViewModel.js b/src/domain/login/PasswordLoginViewModel.js index 0d534b90..7ba75c18 100644 --- a/src/domain/login/PasswordLoginViewModel.js +++ b/src/domain/login/PasswordLoginViewModel.js @@ -30,8 +30,8 @@ export class PasswordLoginViewModel extends ViewModel { get isBusy() { return this._isBusy; } get errorMessage() { return this._errorMessage; } - toggleBusy(state) { - this._isBusy = state; + toggleBusy() { + this._isBusy = !this._isBusy; this.emitChange("isBusy"); } diff --git a/src/domain/login/StartSSOLoginViewModel.js b/src/domain/login/StartSSOLoginViewModel.js index e4c0cf92..bd236788 100644 --- a/src/domain/login/StartSSOLoginViewModel.js +++ b/src/domain/login/StartSSOLoginViewModel.js @@ -25,8 +25,8 @@ export class StartSSOLoginViewModel extends ViewModel{ get isBusy() { return this._isBusy; } - toggleBusy(state) { - this._isBusy = state; + toggleBusy() { + this._isBusy = !this._isBusy; this.emitChange("isBusy"); }