From 90b7754cd6d387f8ca742ca7a065276d5f22ca6f Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 14 Oct 2024 19:33:32 -0700 Subject: [PATCH] refac: collapsible pinned chat list --- src/lib/components/layout/Sidebar.svelte | 138 +++++++++--------- .../layout/Sidebar/SearchInput.svelte | 3 +- 2 files changed, 68 insertions(+), 73 deletions(-) diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index 9a78274bb..1f0f3bf79 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -49,6 +49,9 @@ import AddFilesPlaceholder from '../AddFilesPlaceholder.svelte'; import { select } from 'd3-selection'; import SearchInput from './Sidebar/SearchInput.svelte'; + import ChevronDown from '../icons/ChevronDown.svelte'; + import ChevronUp from '../icons/ChevronUp.svelte'; + import ChevronRight from '../icons/ChevronRight.svelte'; const BREAKPOINT = 768; @@ -65,6 +68,8 @@ let selectedTagName = null; + let showPinnedChat = true; + // Pagination variables let chatListLoading = false; let allChatsLoaded = false; @@ -257,6 +262,8 @@ }; onMount(async () => { + showPinnedChat = localStorage?.showPinnedChat ? localStorage.showPinnedChat === 'true' : true; + mobile.subscribe((e) => { if ($showSidebar && e) { showSidebar.set(false); @@ -476,11 +483,7 @@ {/if} -
+
{#if $temporaryChatEnabled}
{/if} @@ -490,78 +493,71 @@ on:input={searchDebounceHandler} placeholder={$i18n.t('Search')} /> +
- +
+ {#if $temporaryChatEnabled} +
+ {/if} {#if !search && $pinnedChats.length > 0} -
+
-
- {$i18n.t('Pinned')} +
+
- {#each $pinnedChats as chat, idx} - { - selectedChatId = chat.id; - }} - on:unselect={() => { - selectedChatId = null; - }} - on:delete={(e) => { - if ((e?.detail ?? '') === 'shift') { - deleteChatHandler(chat.id); - } else { - deleteChat = chat; - showDeleteConfirm = true; - } - }} - on:tag={(e) => { - const { type, name } = e.detail; - tagEventHandler(type, name, chat.id); - }} - /> - {/each} + {#if showPinnedChat} +
+ {#each $pinnedChats as chat, idx} + { + selectedChatId = chat.id; + }} + on:unselect={() => { + selectedChatId = null; + }} + on:delete={(e) => { + if ((e?.detail ?? '') === 'shift') { + deleteChatHandler(chat.id); + } else { + deleteChat = chat; + showDeleteConfirm = true; + } + }} + on:tag={(e) => { + const { type, name } = e.detail; + tagEventHandler(type, name, chat.id); + }} + /> + {/each} +
+ {/if}
{/if} diff --git a/src/lib/components/layout/Sidebar/SearchInput.svelte b/src/lib/components/layout/Sidebar/SearchInput.svelte index 08d0efc0a..04af4109d 100644 --- a/src/lib/components/layout/Sidebar/SearchInput.svelte +++ b/src/lib/components/layout/Sidebar/SearchInput.svelte @@ -71,7 +71,7 @@ }); -
+