From 2cca45221b7bd1dc3d65361a341a7310271a280d Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Thu, 14 Dec 2023 16:43:33 -0800
Subject: feat(sequelspy): save options

---
 src/lib/Tools/CharacterBirthdays.svelte | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

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

diff --git a/src/lib/Tools/CharacterBirthdays.svelte b/src/lib/Tools/CharacterBirthdays.svelte
index 048a6078..936db0c3 100644
--- a/src/lib/Tools/CharacterBirthdays.svelte
+++ b/src/lib/Tools/CharacterBirthdays.svelte
@@ -4,7 +4,7 @@
 	import { ACDBBirthdays, type ACDBBirthday } from '$lib/Birthday/ACDB';
 	import { aniSearchBirthdays, type aniSearchBirthday } from '$lib/Birthday/aniSearch';
 	import Error from '$lib/Error.svelte';
-	import { clearAllParameters } from './tool';
+	import { clearAllParameters, parseOrDefault } from './tool';
 
 	interface Birthday {
 		name: string;
@@ -12,15 +12,10 @@
 		origin?: string;
 	}
 
-	const parseOrDefault = (parameter: string, fallback: number): number =>
-		browser && urlParameters?.size !== 0
-			? parseInt(urlParameters?.get(parameter) || '', 10) || fallback
-			: fallback;
-
 	const urlParameters = browser ? new URLSearchParams(window.location.search) : null;
 	let date = new Date();
-	let month = parseOrDefault('month', date.getMonth() + 1);
-	let day = parseOrDefault('day', date.getDate());
+	let month = parseOrDefault(urlParameters, 'month', date.getMonth() + 1);
+	let day = parseOrDefault(urlParameters, 'day', date.getDate());
 	let anisearchBirthdays: Promise<aniSearchBirthday[]>;
 	let acdbBirthdays: Promise<ACDBBirthday[]>;
 
-- 
cgit v1.2.3

