Merge branch 'main' into stable

This commit is contained in:
Sam 2023-05-31 16:39:00 +02:00
commit 8c4d8ec3e1
No known key found for this signature in database
GPG key ID: B4EF20DDE721CAA1
3 changed files with 107 additions and 3 deletions

View file

@ -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) {

View file

@ -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<SnapshotData> = {
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
},
};
</script>
<svelte:head>

View file

@ -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<SnapshotData> = {
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;
},
};
</script>
<svelte:head>