From 352ea4a7809fd8c8d4fcdc4281446190045c6da5 Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Thu, 7 Nov 2024 18:24:04 +0000 Subject: [PATCH] feat: refactor content category handling and implement chat session management --- app/src/lib/components/RenderExamples.svelte | 10 +-------- app/src/lib/stores/chatStore.svelte.ts | 22 +++++++++++++++++++ app/src/lib/utils/types.ts | 9 ++++++++ app/src/routes/+layout.server.ts | 4 +++- app/src/routes/+layout.svelte | 20 ++++++++--------- .../[sessionId=sessionId]/+layout.server.ts | 6 +++++ app/src/routes/[sessionId=sessionId]/+page.ts | 4 +--- 7 files changed, 52 insertions(+), 23 deletions(-) create mode 100644 app/src/lib/stores/chatStore.svelte.ts create mode 100644 app/src/lib/utils/types.ts create mode 100644 app/src/routes/[sessionId=sessionId]/+layout.server.ts diff --git a/app/src/lib/components/RenderExamples.svelte b/app/src/lib/components/RenderExamples.svelte index aac5283..a6e0489 100644 --- a/app/src/lib/components/RenderExamples.svelte +++ b/app/src/lib/components/RenderExamples.svelte @@ -1,13 +1,5 @@ - // $: userSpecification = $sessionStore.userSpecification; + @@ -21,9 +20,10 @@
- {#if $page.data.contentCategory} -

Content Category:

-

{$page.data.contentCategory}

+ {#if $page.data.category} +

+ Content Category: {$page.data.category} +

{:else}

Your preferences and audiocast metadata will appear here diff --git a/app/src/routes/[sessionId=sessionId]/+layout.server.ts b/app/src/routes/[sessionId=sessionId]/+layout.server.ts new file mode 100644 index 0000000..9fb43ea --- /dev/null +++ b/app/src/routes/[sessionId=sessionId]/+layout.server.ts @@ -0,0 +1,6 @@ +import type { LayoutServerLoad } from './$types'; +export const load: LayoutServerLoad = ({ url }) => { + return { + category: url.searchParams.get('category') + }; +}; diff --git a/app/src/routes/[sessionId=sessionId]/+page.ts b/app/src/routes/[sessionId=sessionId]/+page.ts index 8e5a07f..a593689 100644 --- a/app/src/routes/[sessionId=sessionId]/+page.ts +++ b/app/src/routes/[sessionId=sessionId]/+page.ts @@ -2,10 +2,8 @@ import { error, redirect } from '@sveltejs/kit'; import type { PageLoad } from './$types'; export const load: PageLoad = async ({ url, parent }) => { - const category = url.searchParams.get('category'); + const { sessionId, category } = await parent(); if (!category) error(400, 'Audio category was not found'); - - const { sessionId } = await parent(); if (url.pathname !== `/${sessionId}`) redirect(307, '/'); return {