diff --git a/frontend/src/routes/@[username]/+page.svelte b/frontend/src/routes/@[username]/+page.svelte index edb9aae..d4204d4 100644 --- a/frontend/src/routes/@[username]/+page.svelte +++ b/frontend/src/routes/@[username]/+page.svelte @@ -50,7 +50,8 @@ let memberPage = 0; let memberSlice: PartialMember[] = []; $: memberSlice = data.members.slice(memberPage * 20, (memberPage + 1) * 20); - const totalPages = Math.ceil(data.members.length / 20); + let totalPages: number; + $: totalPages = Math.ceil(data.members.length / 20); const prevPage = () => { if (memberPage === 0) { diff --git a/frontend/src/routes/edit/member/[id]/+page.svelte b/frontend/src/routes/edit/member/[id]/+page.svelte index 7ba9080..533c1be 100644 --- a/frontend/src/routes/edit/member/[id]/+page.svelte +++ b/frontend/src/routes/edit/member/[id]/+page.svelte @@ -36,7 +36,7 @@ import EditableName from "../../EditableName.svelte"; import EditablePronouns from "../../EditablePronouns.svelte"; import ErrorAlert from "$lib/components/ErrorAlert.svelte"; - import type { PageData } from "./$types"; + import type { PageData, Snapshot } from "./$types"; import { addToast, delToast } from "$lib/toast"; import { memberNameRegex } from "$lib/api/regex"; import { charCount, renderMarkdown } from "$lib/utils"; @@ -372,6 +372,56 @@ const toggleDeleteOpen = () => (deleteOpen = !deleteOpen); let deleteName = ""; let deleteError: APIError | null = null; + + interface SnapshotData { + bio: string; + name: string; + display_name: string; + links: string[]; + names: FieldEntry[]; + pronouns: Pronoun[]; + fields: Field[]; + flags: PrideFlag[]; + unlisted: boolean; + + avatar: string | null; + newName: string; + newPronouns: string; + newLink: string; + } + + export const snapshot: Snapshot = { + capture: () => ({ + bio, + name, + display_name, + links, + names, + pronouns, + fields, + flags, + unlisted, + avatar, + newName, + newPronouns, + newLink, + }), + restore: (value) => { + bio = value.bio + name = value.name + display_name = value.display_name + links = value.links + names = value.names + pronouns = value.pronouns + fields = value.fields + flags = value.flags + unlisted = value.unlisted + avatar = value.avatar + newName = value.newName + newPronouns = value.newPronouns + newLink = value.newLink + }, + }; diff --git a/frontend/src/routes/edit/profile/+page.svelte b/frontend/src/routes/edit/profile/+page.svelte index f2ee796..d0a480e 100644 --- a/frontend/src/routes/edit/profile/+page.svelte +++ b/frontend/src/routes/edit/profile/+page.svelte @@ -35,7 +35,7 @@ import EditablePronouns from "../EditablePronouns.svelte"; import ErrorAlert from "$lib/components/ErrorAlert.svelte"; import { addToast, delToast } from "$lib/toast"; - import type { PageData } from "./$types"; + import type { PageData, Snapshot } from "./$types"; import { charCount, renderMarkdown } from "$lib/utils"; import MarkdownHelp from "../MarkdownHelp.svelte"; import prettyBytes from "pretty-bytes"; @@ -378,6 +378,59 @@ delToast(toastId); } }; + + interface SnapshotData { + bio: string; + display_name: string; + member_title: string; + links: string[]; + names: FieldEntry[]; + pronouns: Pronoun[]; + fields: Field[]; + flags: PrideFlag[]; + list_private: boolean; + custom_preferences: CustomPreferences; + + avatar: string | null; + newName: string; + newPronouns: string; + newLink: string; + } + + export const snapshot: Snapshot = { + capture: () => ({ + bio, + display_name, + member_title, + links, + names, + pronouns, + fields, + flags, + list_private, + custom_preferences, + avatar, + newName, + newPronouns, + newLink, + }), + restore: (value) => { + bio = value.bio; + display_name = value.display_name; + member_title = value.member_title; + links = value.links; + names = value.names; + pronouns = value.pronouns; + fields = value.fields; + flags = value.flags; + list_private = value.list_private; + custom_preferences = value.custom_preferences; + avatar = value.avatar; + newName = value.newName; + newPronouns = value.newPronouns; + newLink = value.newLink; + }, + };