From b6cc5bb130bdcd923ab89a1a92cca0bca39eac63 Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 7 Sep 2023 17:04:18 +0200 Subject: [PATCH] change frontend API calls to use snowflake IDs --- frontend/src/lib/api/entities.ts | 4 ++++ frontend/src/routes/@[username]/+page.svelte | 2 +- frontend/src/routes/@[username]/[memberName]/+page.svelte | 2 +- .../src/routes/@[username]/[memberName]/edit/+layout.svelte | 4 ++-- .../routes/@[username]/[memberName]/edit/other/+page.svelte | 2 +- frontend/src/routes/reports/+page.ts | 3 +-- frontend/src/routes/settings/+page.svelte | 6 +++++- frontend/src/routes/settings/flags/+page.svelte | 2 +- frontend/src/routes/settings/flags/Flag.svelte | 4 ++-- 9 files changed, 18 insertions(+), 11 deletions(-) diff --git a/frontend/src/lib/api/entities.ts b/frontend/src/lib/api/entities.ts index b635c8b..1b3a776 100644 --- a/frontend/src/lib/api/entities.ts +++ b/frontend/src/lib/api/entities.ts @@ -7,6 +7,7 @@ export const MAX_FLAGS = 500; export interface User { id: string; + id_new: string; sid: string; name: string; display_name: string | null; @@ -79,6 +80,7 @@ export interface Pronoun { export interface PartialMember { id: string; + id_new: string; sid: string; name: string; display_name: string | null; @@ -99,6 +101,7 @@ export interface Member extends PartialMember { export interface MemberPartialUser { id: string; + id_new: string; name: string; display_name: string | null; avatar: string | null; @@ -107,6 +110,7 @@ export interface MemberPartialUser { export interface PrideFlag { id: string; + id_new: string; hash: string; name: string; description: string | null; diff --git a/frontend/src/routes/@[username]/+page.svelte b/frontend/src/routes/@[username]/+page.svelte index 76da6de..56542fc 100644 --- a/frontend/src/routes/@[username]/+page.svelte +++ b/frontend/src/routes/@[username]/+page.svelte @@ -274,7 +274,7 @@ /> {/if} {#if $userStore && $userStore.id !== data.id} - + {/if} diff --git a/frontend/src/routes/@[username]/[memberName]/+page.svelte b/frontend/src/routes/@[username]/[memberName]/+page.svelte index 9089959..cef3271 100644 --- a/frontend/src/routes/@[username]/[memberName]/+page.svelte +++ b/frontend/src/routes/@[username]/[memberName]/+page.svelte @@ -170,7 +170,7 @@ /> {/if} {#if $userStore && $userStore.id !== data.user.id} - + {/if} diff --git a/frontend/src/routes/@[username]/[memberName]/edit/+layout.svelte b/frontend/src/routes/@[username]/[memberName]/edit/+layout.svelte index b5e98a3..df02160 100644 --- a/frontend/src/routes/@[username]/[memberName]/edit/+layout.svelte +++ b/frontend/src/routes/@[username]/[memberName]/edit/+layout.svelte @@ -34,7 +34,7 @@ const deleteMember = async () => { try { - await fastFetchClient(`/members/${data.member.id}`, "DELETE"); + await fastFetchClient(`/members/${data.member.id_new}`, "DELETE"); toggleDeleteOpen(); addToast({ @@ -68,7 +68,7 @@ }); try { - const resp = await apiFetchClient(`/members/${data.member.id}`, "PATCH", { + const resp = await apiFetchClient(`/members/${data.member.id_new}`, "PATCH", { name: $member.name, display_name: $member.display_name, avatar: $member.avatar, diff --git a/frontend/src/routes/@[username]/[memberName]/edit/other/+page.svelte b/frontend/src/routes/@[username]/[memberName]/edit/other/+page.svelte index ca29a26..9f3f157 100644 --- a/frontend/src/routes/@[username]/[memberName]/edit/other/+page.svelte +++ b/frontend/src/routes/@[username]/[memberName]/edit/other/+page.svelte @@ -25,7 +25,7 @@ const rerollSid = async () => { try { - const resp = await apiFetchClient(`/members/${data.member.id}/reroll`); + const resp = await apiFetchClient(`/members/${data.member.id_new}/reroll`); addToast({ header: "Success", body: "Rerolled short ID!" }); error = null; $member.sid = resp.sid; diff --git a/frontend/src/routes/reports/+page.ts b/frontend/src/routes/reports/+page.ts index ee1743e..fdeef02 100644 --- a/frontend/src/routes/reports/+page.ts +++ b/frontend/src/routes/reports/+page.ts @@ -1,6 +1,5 @@ -import { ErrorCode, type APIError, type Report } from "$lib/api/entities"; +import type { Report } from "$lib/api/entities"; import { apiFetchClient } from "$lib/api/fetch"; -import { error } from "@sveltejs/kit"; export const load = async ({ url }) => { const { searchParams } = url; diff --git a/frontend/src/routes/settings/+page.svelte b/frontend/src/routes/settings/+page.svelte index ee1f0a3..163698d 100644 --- a/frontend/src/routes/settings/+page.svelte +++ b/frontend/src/routes/settings/+page.svelte @@ -194,7 +194,11 @@ ID - {data.user.id} + {data.user.id_new} + + + xid (deprecated) + {data.user.id} Account created at diff --git a/frontend/src/routes/settings/flags/+page.svelte b/frontend/src/routes/settings/flags/+page.svelte index 4f69c8f..add8fa0 100644 --- a/frontend/src/routes/settings/flags/+page.svelte +++ b/frontend/src/routes/settings/flags/+page.svelte @@ -92,7 +92,7 @@ error = null; addToast({ header: "Deleted flag", body: "Successfully deleted flag!" }); - data.flags = data.flags.filter((entry) => entry.id !== id); + data.flags = data.flags.filter((entry) => entry.id_new !== id); } catch (e) { error = e as APIError; } diff --git a/frontend/src/routes/settings/flags/Flag.svelte b/frontend/src/routes/settings/flags/Flag.svelte index eab228f..a7ae53d 100644 --- a/frontend/src/routes/settings/flags/Flag.svelte +++ b/frontend/src/routes/settings/flags/Flag.svelte @@ -20,7 +20,7 @@ const updateFlag = async () => { try { - const resp = await apiFetchClient(`/users/@me/flags/${flag.id}`, "PATCH", { + const resp = await apiFetchClient(`/users/@me/flags/${flag.id_new}`, "PATCH", { name, description: description || null, }); @@ -65,7 +65,7 @@ Are you sure you want to delete the {flag.name} flag? This cannot be undone! - +