Fix error handling and revert mode in AdminUiHandler

This commit is contained in:
Frederico Santos 2024-08-29 23:59:19 +01:00
parent e4da48f51a
commit 8bf44a2047
1 changed files with 5 additions and 4 deletions

View File

@ -64,12 +64,13 @@ export default class AdminUiHandler extends FormModalUiHandler {
Utils.apiPost("admin/account/discord-link", `username=${encodeURIComponent(this.inputs[0].text)}&discordId=${encodeURIComponent(this.inputs[1].text)}`, "application/x-www-form-urlencoded", true) Utils.apiPost("admin/account/discord-link", `username=${encodeURIComponent(this.inputs[0].text)}&discordId=${encodeURIComponent(this.inputs[1].text)}`, "application/x-www-form-urlencoded", true)
.then(response => { .then(response => {
if (!response.ok) { if (!response.ok) {
return response.text(); console.error(response);
} }
return response.json(); this.scene.ui.revertMode();
}) })
.then(response => { .catch((err) => {
this.scene.ui.setMode(Mode.ADMIN, config); console.error(err);
this.scene.ui.revertMode();
}); });
return false; return false;
}; };