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 { export interface User {
id: string; id: string;
id_new: string;
sid: string; sid: string;
name: string; name: string;
display_name: string | null; display_name: string | null;
@ -79,6 +80,7 @@ export interface Pronoun {
export interface PartialMember { export interface PartialMember {
id: string; id: string;
id_new: string;
sid: string; sid: string;
name: string; name: string;
display_name: string | null; display_name: string | null;
@ -99,6 +101,7 @@ export interface Member extends PartialMember {
export interface MemberPartialUser { export interface MemberPartialUser {
id: string; id: string;
id_new: string;
name: string; name: string;
display_name: string | null; display_name: string | null;
avatar: string | null; avatar: string | null;
@ -107,6 +110,7 @@ export interface MemberPartialUser {
export interface PrideFlag { export interface PrideFlag {
id: string; id: string;
id_new: string;
hash: string; hash: string;
name: string; name: string;
description: string | null; description: string | null;

View file

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

View file

@ -170,7 +170,7 @@
/> />
{/if} {/if}
{#if $userStore && $userStore.id !== data.user.id} {#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} {/if}
</InputGroup> </InputGroup>
</div> </div>

View file

@ -34,7 +34,7 @@
const deleteMember = async () => { const deleteMember = async () => {
try { try {
await fastFetchClient(`/members/${data.member.id}`, "DELETE"); await fastFetchClient(`/members/${data.member.id_new}`, "DELETE");
toggleDeleteOpen(); toggleDeleteOpen();
addToast({ addToast({
@ -68,7 +68,7 @@
}); });
try { 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, name: $member.name,
display_name: $member.display_name, display_name: $member.display_name,
avatar: $member.avatar, avatar: $member.avatar,

View file

@ -25,7 +25,7 @@
const rerollSid = async () => { const rerollSid = async () => {
try { 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!" }); addToast({ header: "Success", body: "Rerolled short ID!" });
error = null; error = null;
$member.sid = resp.sid; $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 { apiFetchClient } from "$lib/api/fetch";
import { error } from "@sveltejs/kit";
export const load = async ({ url }) => { export const load = async ({ url }) => {
const { searchParams } = url; const { searchParams } = url;

View file

@ -194,7 +194,11 @@
<tbody> <tbody>
<tr> <tr>
<th scope="row">ID</th> <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>
<tr> <tr>
<th scope="row">Account created at</th> <th scope="row">Account created at</th>

View file

@ -92,7 +92,7 @@
error = null; error = null;
addToast({ header: "Deleted flag", body: "Successfully deleted flag!" }); 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) { } catch (e) {
error = e as APIError; error = e as APIError;
} }

View file

@ -20,7 +20,7 @@
const updateFlag = async () => { const updateFlag = async () => {
try { 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, name,
description: description || null, description: description || null,
}); });
@ -65,7 +65,7 @@
Are you sure you want to delete the {flag.name} flag? <strong>This cannot be undone!</strong> Are you sure you want to delete the {flag.name} flag? <strong>This cannot be undone!</strong>
</ModalBody> </ModalBody>
<ModalFooter> <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> <Button color="secondary" on:click={toggleDeleteModal}>Cancel</Button>
</ModalFooter> </ModalFooter>
</Modal> </Modal>