mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Set busy state from login vm
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
784b06d500
commit
ff8417dfe2
@ -117,11 +117,15 @@ export class LoginViewModel extends ViewModel {
|
||||
|
||||
async attemptLogin(loginMethod) {
|
||||
this._toggleBusy(true);
|
||||
this._passwordLoginViewModel?.toggleBusy(true);
|
||||
this._startSSOLoginViewModel?.toggleBusy(true);
|
||||
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);
|
||||
const status = loadStatus.get();
|
||||
if (status === LoadStatus.LoginFailed) {
|
||||
return this._sessionContainer.loginFailure;
|
||||
|
@ -30,15 +30,13 @@ export class PasswordLoginViewModel extends ViewModel {
|
||||
|
||||
get isBusy() { return this._isBusy; }
|
||||
|
||||
_toggleBusy(state) {
|
||||
toggleBusy(state) {
|
||||
this._isBusy = state;
|
||||
this.emitChange("isBusy");
|
||||
}
|
||||
|
||||
async login(username, password) {
|
||||
this._toggleBusy(true);
|
||||
const status = await this._attemptLogin(this._loginOptions.password(username, password));
|
||||
this._toggleBusy(false);
|
||||
let error = "";
|
||||
switch (status) {
|
||||
case LoginFailure.Credentials:
|
||||
|
@ -20,6 +20,14 @@ export class StartSSOLoginViewModel extends ViewModel{
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this._sso = options.loginOptions.sso;
|
||||
this._isBusy = false;
|
||||
}
|
||||
|
||||
get isBusy() { return this._isBusy; }
|
||||
|
||||
toggleBusy(state) {
|
||||
this._isBusy = state;
|
||||
this.emitChange("isBusy");
|
||||
}
|
||||
|
||||
async startSSOLogin() {
|
||||
|
@ -57,7 +57,8 @@ class StartSSOLoginView extends TemplateView {
|
||||
t.button({
|
||||
className: "StartSSOLoginView_button button-action secondary",
|
||||
type: "button",
|
||||
onClick: () => vm.startSSOLogin()
|
||||
onClick: () => vm.startSSOLogin(),
|
||||
disabled: vm => vm.isBusy
|
||||
}, vm.i18n`Log in with SSO`)
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user