feat: add toasts when editing profile/members
This commit is contained in:
parent
87e6e2809e
commit
7477814c1b
|
@ -31,6 +31,7 @@
|
||||||
import EditablePronouns from "../../EditablePronouns.svelte";
|
import EditablePronouns from "../../EditablePronouns.svelte";
|
||||||
import ErrorAlert from "$lib/components/ErrorAlert.svelte";
|
import ErrorAlert from "$lib/components/ErrorAlert.svelte";
|
||||||
import type { PageData } from "./$types";
|
import type { PageData } from "./$types";
|
||||||
|
import { addToast, delToast } from "$lib/toast";
|
||||||
|
|
||||||
const MAX_AVATAR_BYTES = 1_000_000;
|
const MAX_AVATAR_BYTES = 1_000_000;
|
||||||
|
|
||||||
|
@ -213,6 +214,12 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateMember = async () => {
|
const updateMember = async () => {
|
||||||
|
const toastId = addToast({
|
||||||
|
header: "Saving changes",
|
||||||
|
body: "Saving changes, please wait...",
|
||||||
|
duration: -1,
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await apiFetchClient<Member>(`/members/${data.member.id}`, "PATCH", {
|
const resp = await apiFetchClient<Member>(`/members/${data.member.id}`, "PATCH", {
|
||||||
name,
|
name,
|
||||||
|
@ -225,12 +232,16 @@
|
||||||
fields,
|
fields,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
addToast({ header: "Success", body: "Successfully saved changes!" });
|
||||||
|
|
||||||
data.member = resp;
|
data.member = resp;
|
||||||
avatar = null;
|
avatar = null;
|
||||||
error = null;
|
error = null;
|
||||||
modified = false;
|
modified = false;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e as APIError;
|
error = e as APIError;
|
||||||
|
} finally {
|
||||||
|
delToast(toastId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
import EditableName from "../EditableName.svelte";
|
import EditableName from "../EditableName.svelte";
|
||||||
import EditablePronouns from "../EditablePronouns.svelte";
|
import EditablePronouns from "../EditablePronouns.svelte";
|
||||||
import ErrorAlert from "$lib/components/ErrorAlert.svelte";
|
import ErrorAlert from "$lib/components/ErrorAlert.svelte";
|
||||||
|
import { addToast, delToast } from "$lib/toast";
|
||||||
|
|
||||||
const MAX_AVATAR_BYTES = 1_000_000;
|
const MAX_AVATAR_BYTES = 1_000_000;
|
||||||
|
|
||||||
|
@ -216,6 +217,12 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateUser = async () => {
|
const updateUser = async () => {
|
||||||
|
const toastId = addToast({
|
||||||
|
header: "Saving changes",
|
||||||
|
body: "Saving changes, please wait...",
|
||||||
|
duration: -1,
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await apiFetchClient<MeUser>("/users/@me", "PATCH", {
|
const resp = await apiFetchClient<MeUser>("/users/@me", "PATCH", {
|
||||||
display_name,
|
display_name,
|
||||||
|
@ -230,11 +237,15 @@
|
||||||
userStore.set(resp);
|
userStore.set(resp);
|
||||||
localStorage.setItem("pronouns-user", JSON.stringify(resp));
|
localStorage.setItem("pronouns-user", JSON.stringify(resp));
|
||||||
|
|
||||||
|
addToast({ header: "Success", body: "Successfully saved changes!" });
|
||||||
|
|
||||||
avatar = null;
|
avatar = null;
|
||||||
error = null;
|
error = null;
|
||||||
modified = false;
|
modified = false;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e as APIError;
|
error = e as APIError;
|
||||||
|
} finally {
|
||||||
|
delToast(toastId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue