This commit is contained in:
Timothy Jaeryang Baek 2026-10-10 20:49:28 +04:00
parent 94e9c7fef9
commit 9fad17558b
2 changed files with 6 additions and 7 deletions

View file

@ -28,6 +28,7 @@
sidebarWidth
} from '$lib/stores';
import {
allLoaded,
loadNextChatListPage,
refreshChatList,
registerFolderRefreshHandler,
@ -116,7 +117,8 @@
// Pagination variables
let chatListLoading = false;
let chatListReady = false;
let allChatsLoaded = false;
// Read pagination state when the shared list publishes its rows.
$: allChatsLoaded = $chats !== null && allLoaded;
let showCreateFolderModal = false;
@ -379,7 +381,6 @@
const initChatList = async () => {
// Reset pagination variables
console.log('initChatList');
allChatsLoaded = false;
chatListReady = false;
await Promise.all([
@ -422,7 +423,6 @@
if (result.accepted) {
await initFolders();
await Promise.all(Object.values(folderRegistry).map((folder) => folder?.setFolderItems?.()));
allChatsLoaded = result.allLoaded;
chatListReady = true;
}
};
@ -434,8 +434,7 @@
chatListLoading = true;
const result = await loadNextChatListPage(localStorage.token);
allChatsLoaded = result.allLoaded;
await loadNextChatListPage(localStorage.token);
chatListLoading = false;
};

View file

@ -15,7 +15,7 @@ export const pinnedChats = readonly(pinnedChatsStore);
let currentPage = 1;
let paginationReady = false;
let requestGeneration = 0;
let allLoaded = false;
export let allLoaded = false;
let loadingNextPage = false;
type RefreshChatListOptions = {
@ -47,9 +47,9 @@ export const refreshChatList = async (
return { accepted: false, allLoaded };
}
chatsStore.set(nextChats);
currentPage = 1;
allLoaded = nextChats.length === 0;
chatsStore.set(nextChats);
if (options.clearPinned) {
pinnedChatsStore.set([]);