change frontend API calls to use snowflake IDs

This commit is contained in:
sam 2023-09-07 17:04:18 +02:00
parent 41f5d46891
commit b6cc5bb130
No known key found for this signature in database
GPG Key ID: B4EF20DDE721CAA1
9 changed files with 18 additions and 11 deletions

View File

@ -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;

View File

@ -274,7 +274,7 @@
/>
{/if}
{#if $userStore && $userStore.id !== data.id}
<ReportButton subject="user" reportUrl="/users/{data.id}/reports" />
<ReportButton subject="user" reportUrl="/users/{data.id_new}/reports" />
{/if}
</InputGroup>
</div>

View File

@ -170,7 +170,7 @@
/>
{/if}
{#if $userStore && $userStore.id !== data.user.id}
<ReportButton subject="member" reportUrl="/members/{data.id}/reports" />
<ReportButton subject="member" reportUrl="/members/{data.id_new}/reports" />
{/if}
</InputGroup>
</div>

View File

@ -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<Member>(`/members/${data.member.id}`, "PATCH", {
const resp = await apiFetchClient<Member>(`/members/${data.member.id_new}`, "PATCH", {
name: $member.name,
display_name: $member.display_name,
avatar: $member.avatar,

View File

@ -25,7 +25,7 @@
const rerollSid = async () => {
try {
const resp = await apiFetchClient<Member>(`/members/${data.member.id}/reroll`);
const resp = await apiFetchClient<Member>(`/members/${data.member.id_new}/reroll`);
addToast({ header: "Success", body: "Rerolled short ID!" });
error = null;
$member.sid = resp.sid;

View File

@ -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;

View File

@ -194,7 +194,11 @@
<tbody>
<tr>
<th scope="row">ID</th>
<td><code>{data.user.id}</code></td>
<td><code>{data.user.id_new}</code></td>
</tr>
<tr>
<th scope="row">xid <em>(deprecated)</em></th>
<td><del><code>{data.user.id}</code></del></td>
</tr>
<tr>
<th scope="row">Account created at</th>

View File

@ -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;
}

View File

@ -20,7 +20,7 @@
const updateFlag = async () => {
try {
const resp = await apiFetchClient<PrideFlag>(`/users/@me/flags/${flag.id}`, "PATCH", {
const resp = await apiFetchClient<PrideFlag>(`/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? <strong>This cannot be undone!</strong>
</ModalBody>
<ModalFooter>
<Button color="danger" on:click={() => deleteFlag(flag.id)}>Delete flag</Button>
<Button color="danger" on:click={() => deleteFlag(flag.id_new)}>Delete flag</Button>
<Button color="secondary" on:click={toggleDeleteModal}>Cancel</Button>
</ModalFooter>
</Modal>