refac
This commit is contained in:
1 parent
2e93987490
commit
86b7bf1f7e
1 file changed
+25
-16
@@ -528,7 +528,6 @@
|
|||||||
let pendingUpsertChats = [];
|
let pendingUpsertChats = [];
|
||||||
|
|
||||||
export const setFolderItems = async (append = false) => {
|
export const setFolderItems = async (append = false) => {
|
||||||
await tick();
|
|
||||||
if (open && chatsLoading) {
|
if (open && chatsLoading) {
|
||||||
if (!append) {
|
if (!append) {
|
||||||
queuedReload = true;
|
queuedReload = true;
|
||||||
@@ -536,11 +535,15 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (open) {
|
||||||
|
chatsLoading = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
await tick();
|
||||||
if (open) {
|
if (open) {
|
||||||
// Always use getSharedFolderChats so owners also see chats
|
// Always use getSharedFolderChats so owners also see chats
|
||||||
// created by users who have write access to this folder.
|
// created by users who have write access to this folder.
|
||||||
const nextPage = append ? chatsPage + 1 : 1;
|
const nextPage = append ? chatsPage + 1 : 1;
|
||||||
chatsLoading = true;
|
|
||||||
try {
|
try {
|
||||||
const res = await getSharedFolderChats(localStorage.token, folderId, {
|
const res = await getSharedFolderChats(localStorage.token, folderId, {
|
||||||
page: nextPage
|
page: nextPage
|
||||||
@@ -584,7 +587,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$: if (open && chats === null) {
|
$: if (open && chats === null && !chatsLoading) {
|
||||||
setFolderItems();
|
setFolderItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -888,7 +891,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div slot="content" class="w-full">
|
<div slot="content" class="w-full">
|
||||||
{#if (folders[folderId]?.childrenIds ?? []).length > 0 || (chats ?? []).length > 0 || hasMoreChats}
|
{#if (folders[folderId]?.childrenIds ?? []).length > 0 || chats !== null || hasMoreChats || chatsLoading}
|
||||||
<div
|
<div
|
||||||
class="ml-3 pl-1 mt-[0.0625rem] flex flex-col overflow-y-auto scrollbar-hidden border-s border-gray-100 dark:border-gray-900"
|
class="ml-3 pl-1 mt-[0.0625rem] flex flex-col overflow-y-auto scrollbar-hidden border-s border-gray-100 dark:border-gray-900"
|
||||||
>
|
>
|
||||||
@@ -925,6 +928,24 @@
|
|||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if chats === null && chatsLoading}
|
||||||
|
<div class="flex gap-1 px-2 py-1.5" aria-label="Loading">
|
||||||
|
<span class="size-1 rounded-full bg-gray-400 animate-pulse dark:bg-gray-600"></span>
|
||||||
|
<span
|
||||||
|
class="size-1 rounded-full bg-gray-400 animate-pulse [animation-delay:150ms] dark:bg-gray-600"
|
||||||
|
></span>
|
||||||
|
<span
|
||||||
|
class="size-1 rounded-full bg-gray-400 animate-pulse [animation-delay:300ms] dark:bg-gray-600"
|
||||||
|
></span>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if chats !== null && chats.length === 0 && !chatsLoading}
|
||||||
|
<div class="px-2 py-0.5 text-[0.6875rem] text-gray-400 dark:text-gray-600">
|
||||||
|
{$i18n.t('No chats')}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#each chats ?? [] as chat (chat.id)}
|
{#each chats ?? [] as chat (chat.id)}
|
||||||
<ChatItem
|
<ChatItem
|
||||||
id={chat.id}
|
id={chat.id}
|
||||||
@@ -968,18 +989,6 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if chats === null && chatsLoading}
|
|
||||||
<div class="flex gap-1 px-2 py-1.5" aria-label="Loading">
|
|
||||||
<span class="size-1 rounded-full bg-gray-400 animate-pulse dark:bg-gray-600"></span>
|
|
||||||
<span
|
|
||||||
class="size-1 rounded-full bg-gray-400 animate-pulse [animation-delay:150ms] dark:bg-gray-600"
|
|
||||||
></span>
|
|
||||||
<span
|
|
||||||
class="size-1 rounded-full bg-gray-400 animate-pulse [animation-delay:300ms] dark:bg-gray-600"
|
|
||||||
></span>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
</Collapsible>
|
</Collapsible>
|
||||||
</div>
|
</div>
|
||||||
Reference in new issue
Block a user