From f9616d34b5bf4bda196ed18730832d95e04947a4 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 18 Feb 2024 06:15:59 -0800 Subject: feat(user): hololive badges --- src/lib/Hololive/hololive.ts | 2 + src/routes/hololive/+page.svelte | 4 +- src/routes/user/[user]/+page.svelte | 121 ++++++++++++++++++++++++++++-------- 3 files changed, 99 insertions(+), 28 deletions(-) diff --git a/src/lib/Hololive/hololive.ts b/src/lib/Hololive/hololive.ts index 6ad97430..4b9ed25e 100644 --- a/src/lib/Hololive/hololive.ts +++ b/src/lib/Hololive/hololive.ts @@ -12,3 +12,5 @@ export interface ParseResult { lives: Live[]; dict: Record; } + +export const typeSchedule = (schedule: object) => schedule as ParseResult; diff --git a/src/routes/hololive/+page.svelte b/src/routes/hololive/+page.svelte index 866fc105..109fbc42 100644 --- a/src/routes/hololive/+page.svelte +++ b/src/routes/hololive/+page.svelte @@ -9,7 +9,7 @@ import root from '$lib/Utility/root'; import identity from '$stores/identity'; import Lives from '$lib/Hololive/Lives.svelte'; - import type { ParseResult } from '$lib/Hololive/hololive'; + import { typeSchedule } from '$lib/Hololive/hololive'; let schedulePromise: Promise; let pinnedStreams: string[] = []; @@ -43,8 +43,6 @@ setSchedule(); }; - - const typeSchedule = (schedule: any) => schedule as ParseResult; diff --git a/src/routes/user/[user]/+page.svelte b/src/routes/user/[user]/+page.svelte index 910a99e2..0d98c9ce 100644 --- a/src/routes/user/[user]/+page.svelte +++ b/src/routes/user/[user]/+page.svelte @@ -1,4 +1,5 @@ @@ -117,39 +143,62 @@ {:catch} {displayBadges(userData.name, '?')} {/await} + + {#if schedule && preferences && preferences.pinned_hololive_streams.length > 0} +

+ +

+ {#each preferences.pinned_hololive_streams as stream} + {@const avatar = schedule.dict[stream]} + + {#if avatar} + + Avatar + + {/if} + {/each} +
+ {/if} {/if} - {#if userData && userData.id === $identity.id} - {#await fetch(root(`/api/preferences?id=${userData.id}`)) then rawPreferences} - {#await rawPreferences.json() then preferences} -

- -

- {$locale().user.preferences.title} - - { - if (userData) - fetch(root(`/api/preferences?id=${userData.id}&toggleHideMissingBadges`), { - method: 'PUT' - }); - }} - checked={preferences.hide_missing_badges} - /> - {$locale().user.preferences.hideMissingBadges.title} - {$locale().user.preferences.hideMissingBadges.hint} -
- {/await} - {/await} + {#if preferences} +

+ +

+ {$locale().user.preferences.title} + + { + if (userData) + fetch(root(`/api/preferences?id=${userData.id}&toggleHideMissingBadges`), { + method: 'PUT' + }); + }} + checked={preferences.hide_missing_badges} + /> + {$locale().user.preferences.hideMissingBadges.title} + {$locale().user.preferences.hideMissingBadges.hint} +
{/if} {/if} - -- cgit v1.2.3