Skip to content

Commit cf7560e

Browse files
committed
feat: add donator emojis where needed
1 parent a9bd834 commit cf7560e

File tree

6 files changed

+36
-24
lines changed

6 files changed

+36
-24
lines changed

src/lib/layouts/stats/PlayerProfile.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
onclick={() => {
193193
if (profile == null) return;
194194
if (!$favorites.some((fav) => fav.uuid === profile.uuid)) {
195-
favorites.set([...$favorites, { uuid: profile.uuid ?? "", ign: profile.username ?? "" }]);
195+
favorites.set([...$favorites, { uuid: profile.uuid ?? "", ign: profile.username ?? "", displayName: profile.displayName ?? undefined }]);
196196
toast.dismiss(toastId);
197197
toastId = toast.success(`Added ${profile.username} to your favorites!`);
198198
} else {

src/lib/shared/api/skycrypt-api.remote.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { prerender, query } from "$app/server";
2-
import { getApiAccessoriesUuidProfileId, getApiBestiaryUuidProfileId, getApiCollectionsUuidProfileId, getApiCrimsonIsleUuidProfileId, getApiDungeonsUuidProfileId, getApiEmbedUuidProfileId, getApiGardenProfileId, getApiGearUuidProfileId, getApiInventoryUuidProfileIdInventoryId, getApiInventoryUuidProfileIdSearchSearch, getApiMinionsUuidProfileId, getApiMiscUuidProfileId, getApiNetworthUuidProfileId, getApiPetsUuidProfileId, getApiPlayerStatsUuidProfileId, getApiResourcepacks, getApiRiftUuidProfileId, getApiSkillsUuidProfileId, getApiSlayerUuidProfileId, getApiStatsUuidProfileId, getApiUuidUsername, type ModelsProcessingError } from "$lib/shared/api/orval-generated";
3-
import { getApiAccessoriesUuidProfileIdParams, getApiBestiaryUuidProfileIdParams, getApiCollectionsUuidProfileIdParams, getApiCrimsonIsleUuidProfileIdParams, getApiDungeonsUuidProfileIdParams, getApiEmbedUuidProfileIdParams, getApiGardenProfileIdParams, getApiGearUuidProfileIdParams, getApiInventoryUuidProfileIdInventoryIdParams, getApiInventoryUuidProfileIdSearchSearchParams, getApiMinionsUuidProfileIdParams, getApiMiscUuidProfileIdParams, getApiNetworthUuidProfileIdParams, getApiPetsUuidProfileIdParams, getApiPlayerStatsUuidProfileIdParams, getApiRiftUuidProfileIdParams, getApiSkillsUuidProfileIdParams, getApiSlayerUuidProfileIdParams, getApiStatsUuidProfileIdParams, getApiUuidUsernameParams } from "$lib/shared/api/orval-generated-zod";
2+
import { getApiAccessoriesUuidProfileId, getApiBestiaryUuidProfileId, getApiCollectionsUuidProfileId, getApiCrimsonIsleUuidProfileId, getApiDungeonsUuidProfileId, getApiEmbedUuidProfileId, getApiGardenProfileId, getApiGearUuidProfileId, getApiInventoryUuidProfileIdInventoryId, getApiInventoryUuidProfileIdSearchSearch, getApiMinionsUuidProfileId, getApiMiscUuidProfileId, getApiNetworthUuidProfileId, getApiPetsUuidProfileId, getApiPlayerStatsUuidProfileId, getApiResourcepacks, getApiRiftUuidProfileId, getApiSkillsUuidProfileId, getApiSlayerUuidProfileId, getApiStatsUuidProfileId, getApiUsernameUuid, getApiUuidUsername, type ModelsProcessingError } from "$lib/shared/api/orval-generated";
3+
import { getApiAccessoriesUuidProfileIdParams, getApiBestiaryUuidProfileIdParams, getApiCollectionsUuidProfileIdParams, getApiCrimsonIsleUuidProfileIdParams, getApiDungeonsUuidProfileIdParams, getApiEmbedUuidProfileIdParams, getApiGardenProfileIdParams, getApiGearUuidProfileIdParams, getApiInventoryUuidProfileIdInventoryIdParams, getApiInventoryUuidProfileIdSearchSearchParams, getApiMinionsUuidProfileIdParams, getApiMiscUuidProfileIdParams, getApiNetworthUuidProfileIdParams, getApiPetsUuidProfileIdParams, getApiPlayerStatsUuidProfileIdParams, getApiRiftUuidProfileIdParams, getApiSkillsUuidProfileIdParams, getApiSlayerUuidProfileIdParams, getApiStatsUuidProfileIdParams, getApiUsernameUuidParams, getApiUuidUsernameParams } from "$lib/shared/api/orval-generated-zod";
44
import { APIEndpointName } from "$types";
55
import { error, isHttpError, redirect } from "@sveltejs/kit";
66

@@ -143,6 +143,11 @@ export const searchUser = query(getApiUuidUsernameParams, async ({ username }) =
143143
error(404, `No user with the name '${username}' was found`);
144144
});
145145

146+
/** Fetch embed data */
147+
export const getUsername = query(getApiUsernameUuidParams, async ({ uuid }) => {
148+
return fetchSection(APIEndpointName.USERNAME, () => getApiUsernameUuid(uuid));
149+
});
150+
146151
/** Fetch packs */
147152
export const getPacks = prerender(async () => {
148153
return fetchSection(APIEndpointName.RESOURCEPACK, () => getApiResourcepacks());

src/lib/stores/favorites.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { persisted } from "svelte-persisted-store";
33

44
// First param `favorites` is the local storage key.
55
// Second param is the initial value.
6-
export const favorites = persisted<{ uuid: string; ign: string }[]>("favorites", []);
6+
export const favorites = persisted<{ uuid: string; ign: string; displayName?: string }[]>("favorites", []);
77

88
// Check if favorites is in old format (string[]) and remove it if so
99
if (browser) {

src/lib/types/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export enum APIEndpointName {
1919
GARDEN = "Garden",
2020
EMBED = "Embed Data",
2121
RESOURCEPACK = "Resource Pack",
22-
SEARCH = "Search"
22+
SEARCH = "Search",
23+
USERNAME = "Username"
2324
}
2425

2526
export * from "./types.d";

src/routes/ contributors.remote.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
import { prerender } from "$app/server";
2-
import { env } from "$env/dynamic/public";
3-
import ky from "ky";
2+
import type { ModelsPlayerResolve } from "$lib/shared/api/orval-generated";
3+
import { getUsername } from "$lib/shared/api/skycrypt-api.remote";
44
import { Role } from "./enums";
55

6-
const { PUBLIC_SERVER_API_URL } = env;
6+
export interface Contributor extends ModelsPlayerResolve {
7+
id: string;
8+
quote?: string;
9+
role?: Role;
10+
}
711

812
export const getContributors = prerender(async () => {
9-
const getUsername = async (uuid: string): Promise<string> => {
13+
const getUsernames = async (uuid: string): Promise<ModelsPlayerResolve> => {
1014
try {
11-
const { username } = await ky(`username/${uuid}`, {
12-
prefixUrl: PUBLIC_SERVER_API_URL
13-
}).json<{ username: string }>();
14-
return username;
15+
return await getUsername({ uuid });
1516
} catch (error) {
1617
console.error(error);
17-
return "???";
18+
return {
19+
displayName: "???",
20+
uuid: uuid,
21+
username: "???"
22+
};
1823
}
1924
};
2025

@@ -34,12 +39,13 @@ export const getContributors = prerender(async () => {
3439
{ id: "b876ec32e396476ba1158438d83c67d4", quote: "Long live the Potato king!", role: Role.TECHNOBLADE }
3540
];
3641

37-
const usernames = await Promise.all(ids.map(({ id }) => getUsername(id)));
42+
const usernames = await Promise.all(ids.map(({ id }) => getUsernames(id)));
3843

3944
return ids.map((contributor, index) => ({
4045
...contributor,
41-
name: usernames[index]
42-
}));
46+
name: usernames[index].username,
47+
displayName: usernames[index].displayName
48+
})) satisfies Contributor[];
4349
};
4450

4551
return contributors();

src/routes/+page.svelte

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { favorites } from "$lib/stores/favorites";
88
import { content } from "$lib/stores/internal";
99
import { performanceMode } from "$lib/stores/preferences";
10-
import { getContributors } from "$routes/ contributors.remote";
10+
import { type Contributor, getContributors } from "$routes/ contributors.remote";
1111
import CodeXml from "@lucide/svelte/icons/code-xml";
1212
import GitPullRequestArrow from "@lucide/svelte/icons/git-pull-request-arrow";
1313
import LoaderCircle from "@lucide/svelte/icons/loader-circle";
@@ -118,10 +118,10 @@
118118

119119
<div class="grid grid-cols-1 gap-5 @xl:grid-cols-2 @5xl:grid-cols-3">
120120
{#if $favorites.length === 0}
121-
{@render profile({ id: "0", name: "No favorites set!", quote: "Why don't you set a favorite?" }, { tip: true })}
121+
{@render profile({ id: "0", username: "No favorites set!", quote: "Why don't you set a favorite?" }, { tip: true })}
122122
{:else}
123123
{#each $favorites.reverse() as favorite, index (index)}
124-
{@render profile({ id: favorite.uuid, name: favorite.ign, role: Role.FAVORITE }, { favorite: true })}
124+
{@render profile({ id: favorite.uuid, username: favorite.ign, role: Role.FAVORITE, displayName: favorite.displayName }, { favorite: true })}
125125
{/each}
126126
{/if}
127127

@@ -142,7 +142,7 @@
142142
</div>
143143
</main>
144144

145-
{#snippet profile(user: { id: string; name: string; quote?: string; role?: Role }, options?: { tip?: boolean; favorite?: boolean })}
145+
{#snippet profile(user: Contributor, options?: { tip?: boolean; favorite?: boolean })}
146146
{#snippet tooltipContent()}
147147
<p class="font-semibold text-text/80 capitalize">
148148
{#if options?.favorite}
@@ -158,14 +158,14 @@
158158
<div class={cn("relative rounded-lg", { "transition-all duration-300 ease-out hover:scale-105": !options?.tip })}>
159159
<Button.Root href={options?.tip ? "#" : `/stats/${user.id}`} class={cn("relative flex h-full min-w-0 items-center gap-4 rounded-lg p-5", $performanceMode ? "bg-background-grey" : "backdrop-blur-lg backdrop-brightness-150 backdrop-contrast-60 dark:backdrop-brightness-50 dark:backdrop-contrast-100")}>
160160
<Avatar.Root class="size-16 shrink-0 rounded-lg bg-text/10">
161-
<Avatar.Image loading="lazy" src={options?.tip ? "https://mc-heads.net/avatar/bc8ea1f51f253ff5142ca11ae45193a4ad8c3ab5e9c6eec8ba7a4fcb7bac40/64" : `https://crafatar.com/avatars/${user.id}?size=64&overlay`} alt={user.name} class="aspect-square size-16 rounded-lg [image-rendering:pixelated]" />
161+
<Avatar.Image loading="lazy" src={options?.tip ? "https://mc-heads.net/avatar/bc8ea1f51f253ff5142ca11ae45193a4ad8c3ab5e9c6eec8ba7a4fcb7bac40/64" : `https://crafatar.com/avatars/${user.id}?size=64&overlay`} alt={user.username} class="aspect-square size-16 rounded-lg [image-rendering:pixelated]" />
162162
<Avatar.Fallback class="flex h-full items-center justify-center text-lg font-semibold text-text/60 uppercase">
163-
{user.name.slice(0, 2)}
163+
{user.username?.slice(0, 2)}
164164
</Avatar.Fallback>
165165
</Avatar.Root>
166166
<div class="flex flex-col justify-center gap-0">
167167
<div class="text-lg font-semibold text-text">
168-
{user.name}
168+
{user.displayName ?? user.username}
169169
</div>
170170
{#if user.quote}
171171
<div class={cn("pr-4 text-sm font-medium text-pretty text-text/80", user.role === Role.TECHNOBLADE ? "italic" : "")}>{@html user.quote}</div>

0 commit comments

Comments
 (0)