diff --git a/src/lib/components/layout/Sidebar/RecursiveFolder.svelte b/src/lib/components/layout/Sidebar/RecursiveFolder.svelte index 58cd428d0d..25d6fc51f9 100644 --- a/src/lib/components/layout/Sidebar/RecursiveFolder.svelte +++ b/src/lib/components/layout/Sidebar/RecursiveFolder.svelte @@ -528,7 +528,6 @@ let pendingUpsertChats = []; export const setFolderItems = async (append = false) => { - await tick(); if (open && chatsLoading) { if (!append) { queuedReload = true; @@ -536,11 +535,15 @@ return; } + if (open) { + chatsLoading = true; + } + + await tick(); if (open) { // Always use getSharedFolderChats so owners also see chats // created by users who have write access to this folder. const nextPage = append ? chatsPage + 1 : 1; - chatsLoading = true; try { const res = await getSharedFolderChats(localStorage.token, folderId, { page: nextPage @@ -584,7 +587,7 @@ } }; - $: if (open && chats === null) { + $: if (open && chats === null && !chatsLoading) { setFolderItems(); } @@ -888,7 +891,7 @@
- {#if (folders[folderId]?.childrenIds ?? []).length > 0 || (chats ?? []).length > 0 || hasMoreChats} + {#if (folders[folderId]?.childrenIds ?? []).length > 0 || chats !== null || hasMoreChats || chatsLoading}
@@ -925,6 +928,24 @@ {/each} {/if} + {#if chats === null && chatsLoading} +
+ + + +
+ {/if} + + {#if chats !== null && chats.length === 0 && !chatsLoading} +
+ {$i18n.t('No chats')} +
+ {/if} + {#each chats ?? [] as chat (chat.id)} {/if} - - {#if chats === null && chatsLoading} -
- - - -
- {/if}