From d9a0544751a178732f0a8d5a2b9b31abd16fa709 Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Fri, 29 Nov 2024 13:23:21 +0000 Subject: [PATCH] Refactor chat components for improved layout and sidebar functionality --- .../lib/components/ChatBoxContainer.svelte | 2 +- app/src/lib/components/ChatContainer.svelte | 23 +++-- app/src/lib/components/Sidebar.svelte | 91 +++++++++++-------- app/src/routes/+layout.svelte | 21 ++++- 4 files changed, 83 insertions(+), 54 deletions(-) diff --git a/app/src/lib/components/ChatBoxContainer.svelte b/app/src/lib/components/ChatBoxContainer.svelte index f3d5e05..cf300e6 100644 --- a/app/src/lib/components/ChatBoxContainer.svelte +++ b/app/src/lib/components/ChatBoxContainer.svelte @@ -8,7 +8,7 @@ export let disabled = false; -
+
diff --git a/app/src/lib/components/ChatContainer.svelte b/app/src/lib/components/ChatContainer.svelte index 14ab83e..0996bc2 100644 --- a/app/src/lib/components/ChatContainer.svelte +++ b/app/src/lib/components/ChatContainer.svelte @@ -2,10 +2,13 @@ import { getSessionContext } from '@/stores/sessionContext.svelte'; import ChatBoxContainer from './ChatBoxContainer.svelte'; import { isfinalResponse } from '@/utils/session.utils'; + import { getAppContext } from '@/stores/appContext.svelte'; export let searchTerm = ''; export let disableTextInput = false; + const { openSettingsDrawer$ } = getAppContext(); + const { sessionCompleted$, fetchingSource$, audioSource$, session$ } = getSessionContext(); let navLoading = false; @@ -15,16 +18,18 @@
-
-
- -
+
+
+
+ +
+
- {#if !hasFinalResponse && !$sessionCompleted$ && !$fetchingSource$ && !$audioSource$} + {#if !hasFinalResponse && !$sessionCompleted$ && !$fetchingSource$ && !$audioSource$} +
- {/if} -
+
+ {/if}
diff --git a/app/src/lib/components/Sidebar.svelte b/app/src/lib/components/Sidebar.svelte index de7e575..14d64dd 100644 --- a/app/src/lib/components/Sidebar.svelte +++ b/app/src/lib/components/Sidebar.svelte @@ -41,15 +41,17 @@ import cs from 'clsx'; import { page } from '$app/stores'; import NewAudiocastButton from './NewAudiocastButton.svelte'; - import { goto } from '$app/navigation'; + import { goto, invalidateAll } from '$app/navigation'; import { env } from '@env'; + import SidebarToggleButton from './SidebarToggleButton.svelte'; + import Logo from './Logo.svelte'; const dispatch = createEventDispatcher<{ clickItem: void }>(); const { openSettingsDrawer$ } = getAppContext(); const { session$, refreshSidebar$ } = getSessionContext(); $: sidebarItems = getSidebarItems(getSessionItems()); - + $: if ($refreshSidebar$ || $session$?.title) { sidebarItems = getSidebarItems(getSessionItems()); } @@ -79,12 +81,23 @@
+
+ openSettingsDrawer$.update((v) => !v)} /> + + + + +
+
- {/if} + {:else} +
+
Last 24 hrs
+ {#each inLast24Hrs as item (item.sessionId)} + + {/each} +
+ +
+
Last 7 days
+ {#each inLast7Days as item (item.sessionId)} + + {/each} +
-
-
Today
- {#each inLast24Hrs as item (item.sessionId)} - - {/each} -
- -
-
Last 7 days
- {#each inLast7Days as item (item.sessionId)} - - {/each} -
- -
-
Last month
- {#each inLast30Days as item (item.sessionId)} - - {/each} -
-
+
+
Last 30 days
+ {#each inLast30Days as item (item.sessionId)} + + {/each} +
+
+ {/if}
diff --git a/app/src/routes/+layout.svelte b/app/src/routes/+layout.svelte index 4ac0741..5db1992 100644 --- a/app/src/routes/+layout.svelte +++ b/app/src/routes/+layout.svelte @@ -10,12 +10,15 @@ import Sidebar from '@/components/Sidebar.svelte'; import { page } from '$app/stores'; import Spinner from '@/components/Spinner.svelte'; - import { setAppContext } from '@/stores/appContext.svelte'; + import { getAppContext, setAppContext } from '@/stores/appContext.svelte'; import { onMount } from 'svelte'; import { getAnalytics, logEvent } from 'firebase/analytics'; + import cs from 'clsx'; export let data; + const { openSettingsDrawer$ } = getAppContext(); + $: sessionId = $page.params.sessionId || data.sessionId; $: setAppContext(); @@ -34,16 +37,24 @@
- - -
+
+ +
+
{#if browser} {#key sessionId} - +
+ +
{/key} {:else}