fix: mail grouping loads all mails at once with large page_size, no infinite scroll during grouping
This commit is contained in:
@@ -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>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user