From f17b350e4e8003f92a58c93ff52a0943210d3b1a Mon Sep 17 00:00:00 2001 From: Josh Creek <8179928+jcreek@users.noreply.github.com> Date: Sat, 10 Jan 2026 18:27:01 +0000 Subject: [PATCH] fix(#64): Address PR comments --- src/routes/+layout.svelte | 17 + src/routes/+page.svelte | 592 +++++++++--------- src/routes/api/pokedexes/+server.ts | 23 +- src/routes/api/pokedexes/[id]/+server.ts | 69 +- src/routes/my-pokedexes/+page.svelte | 18 +- src/routes/welcome/+page.svelte | 4 +- ...001_populate_existing_pokedex_mappings.sql | 7 +- ..._recalculate_pokedex_mappings_function.sql | 28 + ..._pokedex_entries_mapping_select_policy.sql | 16 + 9 files changed, 434 insertions(+), 340 deletions(-) create mode 100644 supabase/migrations/20260110180000_create_recalculate_pokedex_mappings_function.sql create mode 100644 supabase/migrations/20260110190000_fix_pokedex_entries_mapping_select_policy.sql diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index ad63a7c..5ecdc77 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -24,6 +24,19 @@ onMount(async () => { await getUser(); + // Listen for auth state changes to keep the user store in sync + const { + data: { subscription } + } = supabase.auth.onAuthStateChange((event, session) => { + console.log('[Layout] Auth state changed:', event, session ? 'Session found' : 'No session'); + if (session) { + localUser = session.user; + } else { + localUser = null; + } + user.set(localUser); + }); + if (pwaInfo) { const { registerSW } = await import('virtual:pwa-register'); registerSW({ @@ -41,6 +54,10 @@ } }); } + + return () => { + subscription.unsubscribe(); + }; }); async function getUser() { diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index f5f1d0b..2c74681 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -15,6 +15,8 @@ }); onDestroy(unsubscribe); + let isCheckingSession = true; + onMount(() => { checkSessionAndRedirect(); }); @@ -30,6 +32,8 @@ } } catch (error) { console.error('Error checking session:', error); + } finally { + isCheckingSession = false; } } @@ -67,304 +71,322 @@ /> - -
- Track your progress towards a complete Living Pokédex — one of every Pokémon, actively - maintained across your boxes. Join thousands of trainers worldwide. -
- -- A Living Dex is a complete Pokédex where you keep one of every Pokémon in your boxes - (often including forms/variants). Living Dex Tracker helps you build and maintain that - collection with filters, notes, and progress tracking. +{:else} + +
+ Track your progress towards a complete Living Pokédex — one of every Pokémon, actively + maintained across your boxes. Join thousands of trainers worldwide.
-- Easily share your Pokédex journey with friends, or find theirs. If you'd rather go - it alone, that's okay too! -
-- Completely open source and free to use, enabling the community to contribute updates - as soon as new Pokémon are released. -
-- Track simple progress or tackle harder variants like a Living Origin Form Dex with - our powerful filtering options for targeted catching sessions. -
-- Did we mention it's completely free to use? Oh, we did? Good. Because it is. -
-- Get started today with tracking your Living Pokédex progress. It's free, open source, and - built with love for the Pokémon community. -
-- Living Dex Tracker is a fan-made project. We do not claim ownership of any Pokémon - characters, images, or other content featured on this website. This project is not - affiliated with, endorsed, sponsored, or specifically approved by Nintendo, Game Freak, or - The Pokémon Company. -
+ ++ A Living Dex is a complete Pokédex where you keep one of every Pokémon in your boxes + (often including forms/variants). Living Dex Tracker helps you build and maintain that + collection with filters, notes, and progress tracking. +
++ Easily share your Pokédex journey with friends, or find theirs. If you'd rather go + it alone, that's okay too! +
++ Completely open source and free to use, enabling the community to contribute + updates as soon as new Pokémon are released. +
++ Track simple progress or tackle harder variants like a Living Origin Form Dex with + our powerful filtering options for targeted catching sessions. +
++ Did we mention it's completely free to use? Oh, we did? Good. Because it is. +
++ Get started today with tracking your Living Pokédex progress. It's free, open source, and + built with love for the Pokémon community. +
++ Living Dex Tracker is a fan-made project. We do not claim ownership of any Pokémon + characters, images, or other content featured on this website. This project is not + affiliated with, endorsed, sponsored, or specifically approved by Nintendo, Game Freak, + or The Pokémon Company. +
+