diff options
| author | Fuwn <[email protected]> | 2023-12-03 20:46:57 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-12-03 20:46:57 -0800 |
| commit | c3e30d16861671726cea6886bd26560c4524d45d (patch) | |
| tree | 3c0040596028edc4370d8b2070a3b2b42f991ea1 /src | |
| parent | feat(birthdays): reactive url (diff) | |
| download | due.moe-c3e30d16861671726cea6886bd26560c4524d45d.tar.xz due.moe-c3e30d16861671726cea6886bd26560c4524d45d.zip | |
fix(tools): simple reactive url
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/tools/+page.svelte | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/routes/tools/+page.svelte b/src/routes/tools/+page.svelte index 7ea66b17..7862c0d8 100644 --- a/src/routes/tools/+page.svelte +++ b/src/routes/tools/+page.svelte @@ -5,26 +5,25 @@ import EpisodeDiscussionCollector from '$lib/Tools/EpisodeDiscussionCollector.svelte'; import CharacterBirthdays from '$lib/Tools/CharacterBirthdays.svelte'; import { page } from '$app/stores'; - import { goto } from '$app/navigation'; import SequelSpy from '$lib/Tools/SequelSpy.svelte'; export let data; const urlParameters = browser ? new URLSearchParams(window.location.search) : null; - let tool = browser && urlParameters?.size !== 0 ? urlParameters?.get('tool') : 'default'; + let tool = + browser && urlParameters?.size !== 0 ? urlParameters?.get('tool') || 'default' : 'default'; - const changeTool = ( - e: Event & { - currentTarget: EventTarget & HTMLSelectElement; + $: { + if (browser) { + $page.url.searchParams.forEach((_, key) => $page.url.searchParams.delete(key)); + $page.url.searchParams.set('tool', tool); + history.replaceState(null, '', `?${$page.url.searchParams.toString()}`); } - ) => { - $page.url.searchParams.set('tool', (e.target as HTMLSelectElement)?.value); - goto(`?${$page.url.searchParams.toString()}`); - }; + } </script> <p> - <select bind:value={tool} on:change={changeTool}> + <select bind:value={tool}> <option value="default" selected disabled hidden>Tool</option> <option value="todays_character_birthdays">Today's Character Birthdays</option> <option value="activity_history_hole_risks">Activity History Hole Risks</option> |