mirror of
https://codeberg.org/pronounscc/pronouns.cc.git
synced 2024-11-20 08:09:52 +01:00
change frontend API calls to use snowflake IDs
This commit is contained in:
parent
41f5d46891
commit
b6cc5bb130
9 changed files with 18 additions and 11 deletions
|
@ -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;
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue