From 3be493f5b0f0c7b1ee099540c2536dcd1ff2d3e3 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Tue, 14 Jul 2026 04:53:37 -0400 Subject: [PATCH] refac --- src/lib/components/channel/Navbar.svelte | 4 +- .../chat/Settings/ArchivedChats.svelte | 383 ++++++++++ .../chat/Settings/DataControls.svelte | 46 +- src/lib/components/chat/SettingsModal.svelte | 700 ++++++++---------- src/lib/components/layout/Sidebar.svelte | 29 +- src/lib/stores/index.ts | 3 +- src/routes/(app)/notes/+layout.svelte | 2 +- 7 files changed, 709 insertions(+), 458 deletions(-) create mode 100644 src/lib/components/chat/Settings/ArchivedChats.svelte diff --git a/src/lib/components/channel/Navbar.svelte b/src/lib/components/channel/Navbar.svelte index 660b2175cc..11927bcb5f 100644 --- a/src/lib/components/channel/Navbar.svelte +++ b/src/lib/components/channel/Navbar.svelte @@ -2,7 +2,7 @@ import { getContext } from 'svelte'; import { toast } from 'svelte-sonner'; - import { mobile, showArchivedChats, showSidebar, user } from '$lib/stores'; + import { mobile, showSettings, showSidebar, user } from '$lib/stores'; import { slide } from 'svelte/transition'; import { page } from '$app/stores'; @@ -202,7 +202,7 @@ help={true} on:show={(e) => { if (e.detail === 'archived-chat') { - showArchivedChats.set(true); + showSettings.set('archived_chats'); } }} > diff --git a/src/lib/components/chat/Settings/ArchivedChats.svelte b/src/lib/components/chat/Settings/ArchivedChats.svelte new file mode 100644 index 0000000000..67742adb77 --- /dev/null +++ b/src/lib/components/chat/Settings/ArchivedChats.svelte @@ -0,0 +1,383 @@ + + + { + deleteHandler(); + }} +/> + + { + unarchiveAllHandler(); + }} +/> + +
+
+
+
+ {$i18n.t('Archived Chats')} + + {chatCount ?? ''} + +
+ +
+ {$i18n.t('Manage conversations you have archived.')} +
+
+ +
+ + {#if query} + + {/if} +
+ + {#if chatList === null} +
+ +
+ {:else if chatList.length === 0} +
+ {$i18n.t('You have no archived conversations.')} +
+ {:else} +
+ + +
+ +
+ {#each chatList as chat (chat.id)} +
+ { + event.preventDefault(); + showSettings.set(false); + goto(`/c/${chat.id}`); + }} + > + {chat?.title} + + +
+ + + + + + +
+
+ {/each} +
+ + {#if !allChatsLoaded} + { + if (!chatListLoading) { + loadMoreChats(); + } + }} + > +
+ +
{$i18n.t('Loading...')}
+
+
+ {/if} + {/if} +
+ +
+ {#if query === ''} + + + + {/if} +
+
diff --git a/src/lib/components/chat/Settings/DataControls.svelte b/src/lib/components/chat/Settings/DataControls.svelte index e71796da24..71b20106cc 100644 --- a/src/lib/components/chat/Settings/DataControls.svelte +++ b/src/lib/components/chat/Settings/DataControls.svelte @@ -2,24 +2,14 @@ import fileSaver from 'file-saver'; const { saveAs } = fileSaver; - import { - chatId, - user, - settings - } from '$lib/stores'; + import { user } from '$lib/stores'; import { refreshChatList } from '$lib/stores/chat-list'; - import { - archiveAllChats, - deleteAllChats, - getAllChats, - importChats - } from '$lib/apis/chats'; + import { archiveAllChats, deleteAllChats, getAllChats, importChats } from '$lib/apis/chats'; import { getImportOrigin, convertOpenAIChats } from '$lib/utils'; - import { onMount, getContext } from 'svelte'; + import { getContext } from 'svelte'; import { goto } from '$app/navigation'; import { toast } from 'svelte-sonner'; - import ArchivedChatsModal from '$lib/components/layout/ArchivedChatsModal.svelte'; import SharedChatsModal from '$lib/components/layout/SharedChatsModal.svelte'; import FilesModal from '$lib/components/layout/FilesModal.svelte'; import ConfirmDialog from '$lib/components/common/ConfirmDialog.svelte'; @@ -33,7 +23,6 @@ let showArchiveConfirmDialog = false; let showDeleteConfirmDialog = false; - let showArchivedChatsModal = false; let showSharedChatsModal = false; let showFilesModal = false; @@ -118,22 +107,8 @@ await refreshChatList(localStorage.token); }; - - const handleArchivedChatsChange = async () => { - await refreshChatList(localStorage.token); - }; - { - if ($chatId === id) { - goto('/'); - chatId.set(''); - } - }} -/> @@ -205,21 +180,6 @@ {/if} -
-
-
{$i18n.t('Archived Chats')}
- -
-
-
{$i18n.t('Shared Chats')}
diff --git a/src/lib/components/chat/SettingsModal.svelte b/src/lib/components/chat/SettingsModal.svelte index 70f5977483..2ad3ca9683 100644 --- a/src/lib/components/chat/SettingsModal.svelte +++ b/src/lib/components/chat/SettingsModal.svelte @@ -1,5 +1,6 @@ - -
-
-
{$i18n.t('Settings')}
- -
+ + + +
+ {#if selectedTab === 'general'} + { + toast.success($i18n.t('Settings saved successfully!')); + }} + /> + {:else if selectedTab === 'interface'} + { + toast.success($i18n.t('Settings saved successfully!')); + }} + /> + {:else if selectedTab === 'connections'} + ) => { + await saveSettings(updated); + toast.success($i18n.t('Settings saved successfully!')); + }} + /> + {:else if selectedTab === 'tools'} + ) => { + await saveSettings(updated); + toast.success($i18n.t('Settings saved successfully!')); + }} + /> + {:else if selectedTab === 'personalization'} + { + toast.success($i18n.t('Settings saved successfully!')); + }} + /> + {:else if selectedTab === 'audio'} +
diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index 3250ce98f3..d44c2edac2 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -15,7 +15,6 @@ showSidebar, showSearch, mobile, - showArchivedChats, pinnedChats, pinnedNotes, temporaryChatEnabled, @@ -57,7 +56,6 @@ import { createNoteHandler } from '$lib/components/notes/utils'; import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants'; - import ArchivedChatsModal from './ArchivedChatsModal.svelte'; import UserMenu from './Sidebar/UserMenu.svelte'; import ChatItem from './Sidebar/ChatItem.svelte'; import Spinner from '../common/Spinner.svelte'; @@ -704,19 +702,6 @@ const isWindows = /Windows/i.test(navigator.userAgent); - { - await initChatList(); - }} - onDelete={(id) => { - if ($chatId === id) { - goto('/'); - chatId.set(''); - } - }} -/> - { @@ -971,7 +956,7 @@ showActiveUsers={false} on:show={(e) => { if (e.detail === 'archived-chat') { - showArchivedChats.set(true); + showSettings.set('archived_chats'); } }} > @@ -1050,7 +1035,7 @@ @@ -1106,7 +1091,7 @@
-
{$i18n.t('New Chat')}
+
{$i18n.t('New Chat')}
@@ -1128,7 +1113,7 @@
-
{$i18n.t('Search')}
+
{$i18n.t('Search')}
@@ -1204,7 +1189,7 @@
-
{$i18n.t(meta.label)}
+
{$i18n.t(meta.label)}
@@ -1585,7 +1570,7 @@ -
+
{#if $user !== undefined && $user !== null} { if (e.detail === 'archived-chat') { - showArchivedChats.set(true); + showSettings.set('archived_chats'); } }} > diff --git a/src/lib/stores/index.ts b/src/lib/stores/index.ts index 18bd5c922d..7ba3fd54b5 100644 --- a/src/lib/stores/index.ts +++ b/src/lib/stores/index.ts @@ -91,9 +91,8 @@ export const sidebarWidth = writable(245); export const showSidebar = writable(false); export const showSearch = writable(false); -export const showSettings = writable(false); +export const showSettings: Writable = writable(false); export const showShortcuts = writable(false); -export const showArchivedChats = writable(false); export const showChangelog = writable(false); export const showControls = writable(false); diff --git a/src/routes/(app)/notes/+layout.svelte b/src/routes/(app)/notes/+layout.svelte index 2ee8287966..1942b3d576 100644 --- a/src/routes/(app)/notes/+layout.svelte +++ b/src/routes/(app)/notes/+layout.svelte @@ -1,6 +1,6 @@