fix: mail grouping loads all mails at once with large page_size, no infinite scroll during grouping

This commit is contained in:
Agent Zero
2026-07-30 18:44:43 +02:00
parent 7cc07c6e55
commit 3d9c8e03eb
2 changed files with 11 additions and 7 deletions
+9 -6
View File
@@ -193,11 +193,14 @@ export function MailPage() {
setMailsTotal(result.total);
}
} else {
const result = await fetchMails(currentFolderId, mailsPage, sortBy, sortOrder);
// When grouping is active, load all mails at once (no pagination)
const isGrouping = mailGroupState.conditions.length > 0;
const pageToLoad = isGrouping ? 1 : mailsPage;
const result = await fetchMails(currentFolderId, pageToLoad, sortBy, sortOrder, isGrouping ? 10000 : undefined);
// Only update if still on the same folder
if (selectedFolderIdRef.current === currentFolderId) {
// Append for infinite scroll (page > 1), replace on page 1 or folder change
setMails(mailsPage > 1 ? (prev) => [...prev, ...result.mails] : result.mails);
// Append for infinite scroll (page > 1), replace on page 1 or folder change or grouping
setMails(!isGrouping && mailsPage > 1 ? (prev) => [...prev, ...result.mails] : result.mails);
setMailsTotal(result.total);
}
}
@@ -209,7 +212,7 @@ export function MailPage() {
}
}
setLoadingMails(false);
}, [selectedFolderId, mailsPage, searchQuery, sortBy, sortOrder]);
}, [selectedFolderId, mailsPage, searchQuery, sortBy, sortOrder, mailGroupState]);
useEffect(() => {
loadMails();
@@ -908,7 +911,7 @@ export function MailPage() {
setMailsPage((p) => p + 1);
}
}}
hasMore={mails.length < mailsTotal}
hasMore={mailGroupState.conditions.length === 0 && mails.length < mailsTotal}
/>
</ResizablePanel>
@@ -979,7 +982,7 @@ export function MailPage() {
setMailsPage((p) => p + 1);
}
}}
hasMore={mails.length < mailsTotal}
hasMore={mailGroupState.conditions.length === 0 && mails.length < mailsTotal}
/>
</div>
)}