diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index cbc58fd6..003dad41 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -714,9 +714,7 @@ export default function CourrierPage() { -
- {/* Buttons removed from here to avoid duplication with the BulkActionsToolbar */} -
+ {/* Buttons removed from here to avoid duplication with the BulkActionsToolbar */} {/* Email List - Always visible */} @@ -743,7 +741,23 @@ export default function CourrierPage() { ) : (
{/* Email List */} -
+
{ + const target = e.currentTarget; + const { scrollTop, scrollHeight, clientHeight } = target; + const distanceToBottom = scrollHeight - scrollTop - clientHeight; + const scrollPercentage = (scrollTop + clientHeight) / scrollHeight; + + console.log(`[DEBUG-WRAPPER-SCROLL] Distance to bottom: ${distanceToBottom}px, percentage: ${Math.round(scrollPercentage * 100)}%, hasMoreEmails: ${page < totalPages}, isLoading: ${isLoading}`); + + // If near bottom and not already loading and has more emails + if (distanceToBottom < 300 && !isLoading && page < totalPages) { + console.log(`[DEBUG-WRAPPER-TRIGGER] Calling handleLoadMore from wrapper`); + handleLoadMore(); + } + }} + > {emails.length === 0 ? (