This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-14 01:39:40 -04:00
1 parent 34813573fa
commit 6e14d0d627
22 files changed
+249 -243

No files matched your search

+2 -7
View File
@@ -14,7 +14,6 @@
archiveChatById,
updateChatById,
updateChatFolderIdById,
getPinnedChatList,
getAllTags
} from '$lib/apis/chats';
import Spinner from '../common/Spinner.svelte';
@@ -28,12 +27,10 @@
import {
config,
user,
chats,
chatId as currentChatId,
pinnedChats,
currentChatPage,
tags
} from '$lib/stores';
import { refreshChatList } from '$lib/stores/chat-list';
import Messages from '../chat/Messages.svelte';
import { goto } from '$app/navigation';
import PencilSquare from '../icons/PencilSquare.svelte';
@@ -73,9 +70,7 @@
let generating = false;
const refreshSidebar = async () => {
currentChatPage.set(1);
await chats.set(await getChatList(localStorage.token, $currentChatPage));
await pinnedChats.set(await getPinnedChatList(localStorage.token));
await refreshChatList(localStorage.token, { refreshPinned: true });
};
const cloneChatHandler = async (id) => {
+11 -28
View File
@@ -18,8 +18,6 @@
showArchivedChats,
pinnedChats,
pinnedNotes,
scrollPaginationEnabled,
currentChatPage,
temporaryChatEnabled,
channels,
socket,
@@ -31,6 +29,7 @@
sidebarWidth,
activeChatIds
} from '$lib/stores';
import { loadNextChatListPage, refreshChatList } from '$lib/stores/chat-list';
import { onMount, getContext, tick, onDestroy } from 'svelte';
const i18n = getContext('i18n');
@@ -38,9 +37,7 @@
$: canImportChats = $user?.role === 'admin' || ($user?.permissions?.chat?.import ?? true);
import {
getChatList,
getAllTags,
getPinnedChatList,
toggleChatPinnedStatusById,
getChatById,
updateChatFolderIdById,
@@ -97,6 +94,7 @@
// Pagination variables
let chatListLoading = false;
let chatListReady = false;
let allChatsLoaded = false;
let showCreateFolderModal = false;
@@ -323,9 +321,8 @@
const initChatList = async () => {
// Reset pagination variables
console.log('initChatList');
currentChatPage.set(1);
allChatsLoaded = false;
scrollPaginationEnabled.set(false);
chatListReady = false;
initFolders();
initSharedFolders();
@@ -335,11 +332,6 @@
const _tags = await getAllTags(localStorage.token);
tags.set(_tags);
})(),
(async () => {
console.log('Init pinned chats');
const _pinnedChats = await getPinnedChatList(localStorage.token);
pinnedChats.set(_pinnedChats);
})(),
(async () => {
if (
$config?.features?.enable_notes &&
@@ -352,29 +344,20 @@
})(),
(async () => {
console.log('Init chat list');
const _chats = await getChatList(localStorage.token, $currentChatPage);
await chats.set(_chats);
const result = await refreshChatList(localStorage.token, { refreshPinned: true });
if (result.accepted) {
allChatsLoaded = result.allLoaded;
chatListReady = true;
}
})()
]);
// Enable pagination
scrollPaginationEnabled.set(true);
};
const loadMoreChats = async () => {
chatListLoading = true;
currentChatPage.set($currentChatPage + 1);
let newChatList = [];
newChatList = await getChatList(localStorage.token, $currentChatPage);
// once the bottom of the list has been reached (no results) there is no need to continue querying
allChatsLoaded = newChatList.length === 0;
const existingIds = new Set(($chats ?? []).map((c) => c.id));
const uniqueNewChats = newChatList.filter((c) => !existingIds.has(c.id));
await chats.set([...($chats ? $chats : []), ...uniqueNewChats]);
const result = await loadNextChatListPage(localStorage.token);
allChatsLoaded = result.allLoaded;
chatListLoading = false;
};
@@ -1573,7 +1556,7 @@
/>
{/each}
{#if $scrollPaginationEnabled && !allChatsLoaded}
{#if chatListReady && !allChatsLoaded}
<Loader
on:visible={(e) => {
if (!chatListLoading) {
@@ -15,26 +15,22 @@
deleteChatById,
getAllTags,
getChatById,
getChatList,
getChatListByTagName,
getPinnedChatList,
updateChatById,
updateChatFolderIdById
} from '$lib/apis/chats';
import {
chatId,
chatTitle as _chatTitle,
chats,
mobile,
pinnedChats,
showSidebar,
currentChatPage,
tags,
selectedFolder,
activeChatIds,
settings,
user
} from '$lib/stores';
import { refreshChatList } from '$lib/stores/chat-list';
import ChatMenu from './ChatMenu.svelte';
import DeleteConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
@@ -137,9 +133,7 @@
_chatTitle.set(title);
}
currentChatPage.set(1);
await chats.set(await getChatList(localStorage.token, $currentChatPage));
await pinnedChats.set(await getPinnedChatList(localStorage.token));
await refreshChatList(localStorage.token, { refreshPinned: true });
dispatch('change');
}
@@ -165,9 +159,7 @@
if (res) {
goto(`/c/${res.id}`);
currentChatPage.set(1);
await chats.set(await getChatList(localStorage.token, $currentChatPage));
await pinnedChats.set(await getPinnedChatList(localStorage.token));
await refreshChatList(localStorage.token, { refreshPinned: true });
}
};
@@ -231,9 +223,7 @@
);
if (res) {
currentChatPage.set(1);
await chats.set(await getChatList(localStorage.token, $currentChatPage));
await pinnedChats.set(await getPinnedChatList(localStorage.token));
await refreshChatList(localStorage.token, { refreshPinned: true });
dispatch('change');