diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index 4cb20b6940..3e72f0a23e 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -940,110 +940,115 @@ } }} > - {#if $pinnedChats.length > 0} -
- { - localStorage.setItem('showPinnedChat', e.detail); - console.log(e.detail); - }} - on:import={(e) => { - importChatHandler(e.detail, true); - }} - on:drop={async (e) => { - const { type, id, item } = e.detail; + {#if folders || $pinnedChats.length > 0} +
+ {#if folders} + { + selectedFolder.set(null); + initChatList(); + }} + on:update={() => { + initChatList(); + }} + on:import={(e) => { + const { folderId, items } = e.detail; + importChatHandler(items, false, folderId); + }} + on:change={async () => { + initChatList(); + }} + /> + {/if} - if (type === 'chat') { - let chat = await getChatById(localStorage.token, id).catch((error) => { - return null; - }); - if (!chat && item) { - chat = await importChat( - localStorage.token, - item.chat, - item?.meta ?? {}, - false, - null, - item?.created_at ?? null, - item?.updated_at ?? null - ); - } + {#if $pinnedChats.length > 0} +
+ { + localStorage.setItem('showPinnedChat', e.detail); + console.log(e.detail); + }} + on:import={(e) => { + importChatHandler(e.detail, true); + }} + on:drop={async (e) => { + const { type, id, item } = e.detail; - if (chat) { - console.log(chat); - if (chat.folder_id) { - const res = await updateChatFolderIdById( - localStorage.token, - chat.id, - null - ).catch((error) => { - toast.error(`${error}`); + if (type === 'chat') { + let chat = await getChatById(localStorage.token, id).catch((error) => { return null; }); - } + if (!chat && item) { + chat = await importChat( + localStorage.token, + item.chat, + item?.meta ?? {}, + false, + null, + item?.created_at ?? null, + item?.updated_at ?? null + ); + } - if (!chat.pinned) { - const res = await toggleChatPinnedStatusById(localStorage.token, chat.id); - } + if (chat) { + console.log(chat); + if (chat.folder_id) { + const res = await updateChatFolderIdById( + localStorage.token, + chat.id, + null + ).catch((error) => { + toast.error(`${error}`); + return null; + }); + } - initChatList(); - } - } - }} - name={$i18n.t('Pinned')} - > -
- {#each $pinnedChats as chat, idx (`pinned-chat-${chat?.id ?? idx}`)} - { - selectedChatId = chat.id; - }} - on:unselect={() => { - selectedChatId = null; - }} - on:change={async () => { - initChatList(); - }} - on:tag={(e) => { - const { type, name } = e.detail; - tagEventHandler(type, name, chat.id); - }} - /> - {/each} + if (!chat.pinned) { + const res = await toggleChatPinnedStatusById( + localStorage.token, + chat.id + ); + } + + initChatList(); + } + } + }} + name={$i18n.t('Pinned')} + > +
+ {#each $pinnedChats as chat, idx (`pinned-chat-${chat?.id ?? idx}`)} + { + selectedChatId = chat.id; + }} + on:unselect={() => { + selectedChatId = null; + }} + on:change={async () => { + initChatList(); + }} + on:tag={(e) => { + const { type, name } = e.detail; + tagEventHandler(type, name, chat.id); + }} + /> + {/each} +
+
-
-
- {/if} - - {#if folders} -
- { - selectedFolder.set(null); - initChatList(); - }} - on:update={() => { - initChatList(); - }} - on:import={(e) => { - const { folderId, items } = e.detail; - importChatHandler(items, false, folderId); - }} - on:change={async () => { - initChatList(); - }} - /> + {/if}
{/if} diff --git a/src/lib/components/layout/Sidebar/RecursiveFolder.svelte b/src/lib/components/layout/Sidebar/RecursiveFolder.svelte index 652c9f55c4..a169998f20 100644 --- a/src/lib/components/layout/Sidebar/RecursiveFolder.svelte +++ b/src/lib/components/layout/Sidebar/RecursiveFolder.svelte @@ -430,7 +430,7 @@