resetStatus from within startLogin

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-08-20 20:05:36 +05:30
parent 9482998b15
commit c650b35831
4 changed files with 5 additions and 7 deletions

View File

@ -59,7 +59,6 @@ export class CompleteSSOLoginViewModel extends ViewModel {
} }
if (error) { if (error) {
this._showError(error); this._showError(error);
this._sessionContainer.resetStatus();
} }
} }
} }

View File

@ -89,7 +89,6 @@ export class LoginViewModel extends ViewModel {
_showPasswordLogin() { _showPasswordLogin() {
this._passwordLoginViewModel = this.track(new PasswordLoginViewModel( this._passwordLoginViewModel = this.track(new PasswordLoginViewModel(
this.childOptions({ this.childOptions({
sessionContainer: this._sessionContainer,
loginOptions: this._loginOptions, loginOptions: this._loginOptions,
homeserver: this._homeserver, homeserver: this._homeserver,
attemptLogin: loginMethod => this.attemptLogin(loginMethod), attemptLogin: loginMethod => this.attemptLogin(loginMethod),

View File

@ -20,8 +20,7 @@ import {LoginFailure} from "../../matrix/SessionContainer.js";
export class PasswordLoginViewModel extends ViewModel { export class PasswordLoginViewModel extends ViewModel {
constructor(options) { constructor(options) {
super(options); super(options);
const {loginOptions, sessionContainer, homeserver, attemptLogin, showError} = options; const {loginOptions, homeserver, attemptLogin, showError} = options;
this._sessionContainer = sessionContainer;
this._loginOptions = loginOptions; this._loginOptions = loginOptions;
this._attemptLogin = attemptLogin; this._attemptLogin = attemptLogin;
this._showError = showError; this._showError = showError;
@ -54,7 +53,6 @@ export class PasswordLoginViewModel extends ViewModel {
} }
if (error) { if (error) {
this._showError(error); this._showError(error);
this._sessionContainer.resetStatus();
} }
} }
} }

View File

@ -129,9 +129,11 @@ export class SessionContainer {
} }
async startWithLogin(loginMethod) { async startWithLogin(loginMethod) {
if (this._status.get() !== LoadStatus.NotLoading) { const currentStatus = this._status.get();
if (currentStatus !== LoadStatus.LoginFailed && currentStatus !== LoadStatus.NotLoading) {
return; return;
} }
this._resetStatus();
await this._platform.logger.run("login", async log => { await this._platform.logger.run("login", async log => {
this._status.set(LoadStatus.Login); this._status.set(LoadStatus.Login);
const clock = this._platform.clock; const clock = this._platform.clock;
@ -354,7 +356,7 @@ export class SessionContainer {
} }
} }
resetStatus() { _resetStatus() {
this._status.set(LoadStatus.NotLoading); this._status.set(LoadStatus.NotLoading);
this._error = null; this._error = null;
this._loginFailure = null; this._loginFailure = null;