From ded5e5bf084ce424c05066ad9c6f418672345aac Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Sun, 6 Oct 2024 03:49:02 -0700
Subject: feat(badges): use preferences graphql api

---
 src/lib/User/BadgeWall/AWC.svelte | 68 ++++++++++++++++++++-------------------
 1 file changed, 35 insertions(+), 33 deletions(-)

(limited to 'src/lib/User/BadgeWall/AWC.svelte')

diff --git a/src/lib/User/BadgeWall/AWC.svelte b/src/lib/User/BadgeWall/AWC.svelte
index c2268510..ba8a22ea 100644
--- a/src/lib/User/BadgeWall/AWC.svelte
+++ b/src/lib/User/BadgeWall/AWC.svelte
@@ -1,14 +1,14 @@
 <script lang="ts">
 	import type { AWCBadgesGroup } from '$lib/Data/awc';
-	import type { UserPreferences } from '$lib/Database/SB/User/preferences';
 	import { cdn, thumbnail } from '$lib/Utility/image';
+	import type { Preferences } from '../../../graphql/$types';
 	import FallbackBadge from './FallbackBadge.svelte';
 	import './badges.css';
 
 	export let awcPromise: Promise<Response>;
 	export let categoryFilter: string | null;
 	export let isOwner: boolean;
-	export let preferences: UserPreferences;
+	export let preferences: Preferences;
 
 	const awcBadgesGrouped = (awcResponse: string): AWCBadgesGroup[] => {
 		return Array.from(
@@ -60,39 +60,41 @@
 </script>
 
 {#await awcPromise then badges}
-	{#await badges.clone().text() then text}
-		{@const parsedBadges = awcBadgesGrouped(text)}
+	{#if badges}
+		{#await badges.clone().text() then text}
+			{@const parsedBadges = awcBadgesGrouped(text)}
 
-		{#if parsedBadges.length > 0}
-			{#each parsedBadges as group}
-				<details open={categoryFilter || isOwner ? false : true}>
-					<summary>
-						Anime Watching Club <span class="opaque">|</span>
-						{group.group}
-					</summary>
+			{#if parsedBadges.length > 0}
+				{#each parsedBadges as group}
+					<details open={categoryFilter || isOwner ? false : true}>
+						<summary>
+							Anime Watching Club <span class="opaque">|</span>
+							{group.group}
+						</summary>
 
-					<p />
+						<p />
 
-					<div class="badges">
-						{#each group.badges as badge, index}
-							<div id={`badge-${index}`}>
-								<FallbackBadge
-									{badge}
-									source={cdn(thumbnail(badge.image))}
-									alternative={badge.description}
-									fallback={thumbnail(badge.image)}
-									hideOnError={preferences.hide_missing_badges}
-									awc
-									{index}
-									{preferences}
-								/>
-							</div>
-						{/each}
-					</div>
-				</details>
+						<div class="badges">
+							{#each group.badges as badge, index}
+								<div id={`badge-${index}`}>
+									<FallbackBadge
+										{badge}
+										source={cdn(thumbnail(badge.image))}
+										alternative={badge.description}
+										fallback={thumbnail(badge.image)}
+										hideOnError={preferences.hide_missing_badges}
+										awc
+										{index}
+										{preferences}
+									/>
+								</div>
+							{/each}
+						</div>
+					</details>
 
-				<p />
-			{/each}
-		{/if}
-	{/await}
+					<p />
+				{/each}
+			{/if}
+		{/await}
+	{/if}
 {/await}
-- 
cgit v1.2.3

