mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-13 11:52:18 +02:00
fix holding enter spam
This commit is contained in:
parent
14614eb60a
commit
f52e69bf2e
@ -142,27 +142,29 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
|
||||
this.processExternalProvider(config);
|
||||
const originalLoginAction = this.submitAction;
|
||||
this.submitAction = (_) => {
|
||||
// Prevent overlapping overrides on action modification
|
||||
this.submitAction = originalLoginAction;
|
||||
this.sanitizeInputs();
|
||||
globalScene.ui.setMode(Mode.LOADING, { buttonActions: []});
|
||||
const onFail = error => {
|
||||
globalScene.ui.setMode(Mode.LOGIN_FORM, Object.assign(config, { errorMessage: error?.trim() }));
|
||||
globalScene.ui.playError();
|
||||
};
|
||||
if (!this.inputs[0].text) {
|
||||
return onFail(i18next.t("menu:emptyUsername"));
|
||||
}
|
||||
|
||||
const [ usernameInput, passwordInput ] = this.inputs;
|
||||
|
||||
pokerogueApi.account.login({ username: usernameInput.text, password: passwordInput.text }).then(error => {
|
||||
if (!error) {
|
||||
originalLoginAction && originalLoginAction();
|
||||
} else {
|
||||
onFail(error);
|
||||
if (globalScene.tweens.getTweensOf(this.modalContainer).length === 0) {
|
||||
// Prevent overlapping overrides on action modification
|
||||
this.submitAction = originalLoginAction;
|
||||
this.sanitizeInputs();
|
||||
globalScene.ui.setMode(Mode.LOADING, { buttonActions: []});
|
||||
const onFail = error => {
|
||||
globalScene.ui.setMode(Mode.LOGIN_FORM, Object.assign(config, { errorMessage: error?.trim() }));
|
||||
globalScene.ui.playError();
|
||||
};
|
||||
if (!this.inputs[0].text) {
|
||||
return onFail(i18next.t("menu:emptyUsername"));
|
||||
}
|
||||
});
|
||||
|
||||
const [ usernameInput, passwordInput ] = this.inputs;
|
||||
|
||||
pokerogueApi.account.login({ username: usernameInput.text, password: passwordInput.text }).then(error => {
|
||||
if (!error) {
|
||||
originalLoginAction && originalLoginAction();
|
||||
} else {
|
||||
onFail(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return true;
|
||||
|
@ -91,43 +91,45 @@ export default class RegistrationFormUiHandler extends FormModalUiHandler {
|
||||
|
||||
const originalRegistrationAction = this.submitAction;
|
||||
this.submitAction = (_) => {
|
||||
// Prevent overlapping overrides on action modification
|
||||
this.submitAction = originalRegistrationAction;
|
||||
this.sanitizeInputs();
|
||||
globalScene.ui.setMode(Mode.LOADING, { buttonActions: []});
|
||||
const onFail = error => {
|
||||
globalScene.ui.setMode(Mode.REGISTRATION_FORM, Object.assign(config, { errorMessage: error?.trim() }));
|
||||
globalScene.ui.playError();
|
||||
const errorMessageFontSize = languageSettings[i18next.resolvedLanguage!]?.errorMessageFontSize;
|
||||
if (errorMessageFontSize) {
|
||||
this.errorMessage.setFontSize(errorMessageFontSize);
|
||||
}
|
||||
};
|
||||
if (!this.inputs[0].text) {
|
||||
return onFail(i18next.t("menu:emptyUsername"));
|
||||
}
|
||||
if (!this.inputs[1].text) {
|
||||
return onFail(this.getReadableErrorMessage("invalid password"));
|
||||
}
|
||||
if (this.inputs[1].text !== this.inputs[2].text) {
|
||||
return onFail(i18next.t("menu:passwordNotMatchingConfirmPassword"));
|
||||
}
|
||||
const [ usernameInput, passwordInput ] = this.inputs;
|
||||
pokerogueApi.account.register({ username: usernameInput.text, password: passwordInput.text })
|
||||
.then(registerError => {
|
||||
if (!registerError) {
|
||||
pokerogueApi.account.login({ username: usernameInput.text, password: passwordInput.text })
|
||||
.then(loginError => {
|
||||
if (!loginError) {
|
||||
originalRegistrationAction && originalRegistrationAction();
|
||||
} else {
|
||||
onFail(loginError);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
onFail(registerError);
|
||||
if (globalScene.tweens.getTweensOf(this.modalContainer).length === 0) {
|
||||
// Prevent overlapping overrides on action modification
|
||||
this.submitAction = originalRegistrationAction;
|
||||
this.sanitizeInputs();
|
||||
globalScene.ui.setMode(Mode.LOADING, { buttonActions: []});
|
||||
const onFail = error => {
|
||||
globalScene.ui.setMode(Mode.REGISTRATION_FORM, Object.assign(config, { errorMessage: error?.trim() }));
|
||||
globalScene.ui.playError();
|
||||
const errorMessageFontSize = languageSettings[i18next.resolvedLanguage!]?.errorMessageFontSize;
|
||||
if (errorMessageFontSize) {
|
||||
this.errorMessage.setFontSize(errorMessageFontSize);
|
||||
}
|
||||
});
|
||||
};
|
||||
if (!this.inputs[0].text) {
|
||||
return onFail(i18next.t("menu:emptyUsername"));
|
||||
}
|
||||
if (!this.inputs[1].text) {
|
||||
return onFail(this.getReadableErrorMessage("invalid password"));
|
||||
}
|
||||
if (this.inputs[1].text !== this.inputs[2].text) {
|
||||
return onFail(i18next.t("menu:passwordNotMatchingConfirmPassword"));
|
||||
}
|
||||
const [ usernameInput, passwordInput ] = this.inputs;
|
||||
pokerogueApi.account.register({ username: usernameInput.text, password: passwordInput.text })
|
||||
.then(registerError => {
|
||||
if (!registerError) {
|
||||
pokerogueApi.account.login({ username: usernameInput.text, password: passwordInput.text })
|
||||
.then(loginError => {
|
||||
if (!loginError) {
|
||||
originalRegistrationAction && originalRegistrationAction();
|
||||
} else {
|
||||
onFail(loginError);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
onFail(registerError);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user