From 5b935692a595b976d81e9927374552ed5ab46e8b Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Wed, 20 Dec 2023 14:03:03 -0800
Subject: refactor(sequelspy): use season getter

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

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

diff --git a/src/lib/Tools/SequelSpy.svelte b/src/lib/Tools/SequelSpy.svelte
index 44e453fe..0c81505d 100644
--- a/src/lib/Tools/SequelSpy.svelte
+++ b/src/lib/Tools/SequelSpy.svelte
@@ -8,27 +8,14 @@
 	import type { Media } from '$lib/AniList/media';
 	import { page } from '$app/stores';
 	import { browser } from '$app/environment';
+	import { season as getSeason } from '$lib/Media/Anime/season';
 
 	export let user: AniListAuthorisation;
 
 	let currentPrequels: Promise<MediaPrequel[]> = Promise.resolve([]) as Promise<MediaPrequel[]>;
 	const urlParameters = browser ? new URLSearchParams(window.location.search) : null;
 	let year = parseOrDefault(urlParameters, 'year', new Date().getFullYear());
-	let season = parseOrDefault(
-		urlParameters,
-		'season',
-		(() => {
-			if (new Date().getMonth() >= 0 && new Date().getMonth() <= 2)
-				return 'WINTER' as 'WINTER' | 'SPRING' | 'SUMMER' | 'FALL';
-			else if (new Date().getMonth() >= 3 && new Date().getMonth() <= 5)
-				return 'SPRING' as 'WINTER' | 'SPRING' | 'SUMMER' | 'FALL';
-			else if (new Date().getMonth() >= 6 && new Date().getMonth() <= 8)
-				return 'SUMMER' as 'WINTER' | 'SPRING' | 'SUMMER' | 'FALL';
-			else if (new Date().getMonth() >= 9 && new Date().getMonth() <= 11)
-				return 'FALL' as 'WINTER' | 'SPRING' | 'SUMMER' | 'FALL';
-			else return 'WINTER' as 'WINTER' | 'SPRING' | 'SUMMER' | 'FALL';
-		})()
-	);
+	let season = parseOrDefault(urlParameters, 'season', getSeason());
 
 	$: currentPrequels = prequels(user, year, season);
 	$: {
-- 
cgit v1.2.3

