From 673c3f1adbb076fdfa65eab76a33c20eae740297 Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Tue, 12 Nov 2024 13:40:12 +0000 Subject: [PATCH] pass category to sidebar_item; refactor --- app/src/lib/components/Sidebar.svelte | 14 +++++++++----- app/src/lib/components/SidebarItem.svelte | 12 +++++++++--- .../audiocast/[sessionId=sessionId]/+page.svelte | 15 +++++++++++---- .../chat/[sessionId=sessionId]/+page.svelte | 12 +++++++++--- 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/app/src/lib/components/Sidebar.svelte b/app/src/lib/components/Sidebar.svelte index eaa9a99..c61a5dc 100644 --- a/app/src/lib/components/Sidebar.svelte +++ b/app/src/lib/components/Sidebar.svelte @@ -24,10 +24,10 @@ $: sidebarItems = sessionItems .filter(([_, item]) => item.chats.length) .map(([sessionId, item]) => ({ + sessionId, title: item.title || 'Untitled', nonce: item.nonce, - href: `/chat/${sessionId}?category=${item.category}`, - sessionId + category: item.category })) .sort((a, b) => b.nonce - a.nonce); @@ -44,6 +44,10 @@ ) .filter(([_, v]) => Boolean(v)); } + + function dispatchClickItem() { + dispatch('clickItem'); + }
Today
{#each inLast24Hrs as item} - dispatch('clickItem')} /> + {/each}
Last 7 days
{#each inLast7Days as item} - dispatch('clickItem')} /> + {/each}
Last month
{#each inLast30Days as item} - dispatch('clickItem')} /> + {/each}
diff --git a/app/src/lib/components/SidebarItem.svelte b/app/src/lib/components/SidebarItem.svelte index 7925ef3..017fc0b 100644 --- a/app/src/lib/components/SidebarItem.svelte +++ b/app/src/lib/components/SidebarItem.svelte @@ -1,9 +1,10 @@ @@ -21,13 +22,14 @@ easing: cubicInOut }); + $: href = `/chat/${item.sessionId}?category=${item.category}`; $: isActive = $page.url.href.includes(item.sessionId); diff --git a/app/src/routes/audiocast/[sessionId=sessionId]/+page.svelte b/app/src/routes/audiocast/[sessionId=sessionId]/+page.svelte index 4730660..343577e 100644 --- a/app/src/routes/audiocast/[sessionId=sessionId]/+page.svelte +++ b/app/src/routes/audiocast/[sessionId=sessionId]/+page.svelte @@ -9,9 +9,10 @@ type GenerateAudiocastResponse = { script: string; source_content: string; - created_at?: string; chats: Array>; + category: ContentCategory; title: ChatMetadata['title']; + created_at?: string; }; function parseScript(script: string) { @@ -83,9 +84,15 @@ {:then data}
- {#if data.title} -

{data.title}

- {/if} +
+ + {data.category} + + + {#if data.title} +

{data.title}

+ {/if} +