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) {
this._showError(error);
this._sessionContainer.resetStatus();
}
}
}

View file

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

View file

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

View file

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