From ae63734fd311824dfe5c8314f214f5153fbb1d34 Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Sat, 23 Dec 2023 18:45:42 -0800
Subject: feat(wrapped): genre and tag count options

---
 src/lib/Tools/Wrapped.svelte | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

(limited to 'src/lib/Tools/Wrapped.svelte')

diff --git a/src/lib/Tools/Wrapped.svelte b/src/lib/Tools/Wrapped.svelte
index 69aca735..2bbfdce9 100644
--- a/src/lib/Tools/Wrapped.svelte
+++ b/src/lib/Tools/Wrapped.svelte
@@ -44,6 +44,7 @@
 	let width = 980;
 	let lightMode = false;
 	let highestRatedCount = 5;
+	let genreTagCount = 5;
 	let mounted = false;
 	let generated = false;
 	let disableActivityHistory = true;
@@ -64,6 +65,7 @@
 			$page.url.searchParams.set('width', width.toString());
 			$page.url.searchParams.set('lightMode', lightMode.toString());
 			$page.url.searchParams.set('highestRatedCount', highestRatedCount.toString());
+			$page.url.searchParams.set('genreTagCount', genreTagCount.toString());
 			$page.url.searchParams.set('disableActivityHistory', disableActivityHistory.toString());
 
 			history.replaceState(null, '', `?${$page.url.searchParams.toString()}`);
@@ -83,6 +85,13 @@
 
 		new Promise((resolve) => setTimeout(resolve, 1)).then(updateWidth);
 	}
+	$: {
+		genreTagCount = genreTagCount;
+
+		if (animeList && mangaList) topMedia = tops([...animeList, ...mangaList], genreTagCount);
+
+		// new Promise((resolve) => setTimeout(resolve, 1)).then(updateWidth);
+	}
 	$: {
 		excludedKeywords = excludedKeywords;
 
@@ -152,6 +161,7 @@
 			'width',
 			'forceDark',
 			'highestRatedCount',
+			'genreTagCount',
 			'disableActivityHistory'
 		]);
 
@@ -165,6 +175,7 @@
 			width = parseInt($page.url.searchParams.get('width') || '980', 10);
 			lightMode = $page.url.searchParams.get('lightMode') === 'true';
 			highestRatedCount = parseInt($page.url.searchParams.get('highestRatedCount') || '5', 10);
+			genreTagCount = parseInt($page.url.searchParams.get('genreTagCount') || '5', 10);
 			disableActivityHistory = $page.url.searchParams.get('disableActivityHistory') === 'true';
 		}
 
@@ -245,8 +256,6 @@
 		}
 
 		for (const media of mangaList) chapters += media.mediaListEntry?.progress || 0;
-
-		topMedia = tops([...animeList, ...mangaList], 5);
 	};
 
 	/* eslint-disable @typescript-eslint/no-explicit-any */
@@ -625,6 +634,12 @@
 						{/each}
 					</select>
 					Highest rated media count<br />
+					<select bind:value={genreTagCount}>
+						{#each [3, 4, 5, 6, 7, 8, 9, 10] as count}
+							<option value={count}>{count}</option>
+						{/each}
+					</select>
+					Highest genre and tag count<br />
 					<button on:click={updateWidth}>Find best fit</button>
 					<button on:click={() => (width -= 25)}>-25px</button>
 					<button on:click={() => (width += 25)}>+25px</button>
-- 
cgit v1.2.3

