From f4ac64e88e147c3fbc68ee40edd19c7ce7beaa95 Mon Sep 17 00:00:00 2001 From: Bradley Shellnut Date: Thu, 13 Oct 2022 22:54:44 -0500 Subject: [PATCH] Render games without javascript to the search page. --- src/routes/search/+page.server.ts | 4 ++-- src/routes/search/+page.svelte | 29 +++++++++++++++++++++++++++++ src/search/actions.ts | 2 ++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/routes/search/+page.server.ts b/src/routes/search/+page.server.ts index a001007..16b21a5 100644 --- a/src/routes/search/+page.server.ts +++ b/src/routes/search/+page.server.ts @@ -1,8 +1,8 @@ import type { Actions, PageServerLoad } from '../$types'; import { Games } from '$root/search/actions'; -export const load: PageServerLoad = ({ request }) => { - console.log('page server load request', request) +export const load: PageServerLoad = (v) => { + console.log('page server load request', v) return { games: [], diff --git a/src/routes/search/+page.svelte b/src/routes/search/+page.svelte index af32b20..3e1fd28 100644 --- a/src/routes/search/+page.svelte +++ b/src/routes/search/+page.svelte @@ -17,6 +17,11 @@ gameStore.addAll(data?.games); } + $: if (form?.games) { + gameStore.removeAll(); + gameStore.addAll(form?.games); + } + interface RemoveGameEvent extends Event { detail: GameType | SavedGameType; } @@ -43,3 +48,27 @@ {/if} + + diff --git a/src/search/actions.ts b/src/search/actions.ts index d7c9c70..c0dd25f 100644 --- a/src/search/actions.ts +++ b/src/search/actions.ts @@ -68,6 +68,8 @@ export const Games: Actions = { games.push(mapAPIGameToBoredGame(game)); }); + console.log('returning from search') + return { games, totalCount: games.length