Fix success notification showing when failing to update settings

This commit is contained in:
2026-08-29 18:12:21 +02:00
parent 1329512fbb
commit e14bd80d8d

View File

@@ -34,7 +34,7 @@ export function Settings({
message: "",
},
2000,
)
);
};
const onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
@@ -49,14 +49,19 @@ export function Settings({
const save = async () => {
setLoading(true);
await fetch(`${import.meta.env.VITE_BASE_API_URL}/update`, {
let ok = await fetch(
`${import.meta.env.VITE_BASE_API_URL}/update`,
{
body: JSON.stringify(data),
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
}).catch((e) => {
},
)
.then((r) => r.ok)
.catch((e) => {
notify(
{
type: "danger",
@@ -68,9 +73,11 @@ export function Settings({
);
});
if (ok) {
await update();
setLoading(false);
notifySucess();
}
setLoading(false);
};
save();
@@ -78,9 +85,11 @@ export function Settings({
const loadFromSteam = async () => {
setLoading(true);
await fetch(`${import.meta.env.VITE_BASE_API_URL}/reload`, {
let ok = await fetch(`${import.meta.env.VITE_BASE_API_URL}/reload`, {
credentials: "include",
}).catch((e) => {
})
.then((r) => r.ok)
.catch((e) => {
notify(
{
type: "danger",
@@ -92,9 +101,12 @@ export function Settings({
);
});
if (ok) {
await update();
setLoading(false);
notifySucess();
}
setLoading(false);
};
return (