From 2f53564b1a17f7e57fea365d23c8cbb628b43dff Mon Sep 17 00:00:00 2001 From: alma Date: Mon, 28 Apr 2025 17:23:40 +0200 Subject: [PATCH] courrier multi account restore compose --- app/courrier/page.tsx | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index 3cf9bfbd..c8da2b8a 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -391,31 +391,31 @@ export default function CourrierPage() { // Update accounts state setAccounts(updatedAccounts); console.log('[DEBUG] Updated accounts:', updatedAccounts); + + // Auto-select the first non-All account if available + if (updatedAccounts.length > 1) { + console.log('Auto-selecting account:', updatedAccounts[1]); + setSelectedAccount(updatedAccounts[1]); + setShowFolders(true); + + // Ensure folders are visible for the selected account + setExpandedAccounts(prev => ({ + ...prev, + [updatedAccounts[1].id]: true + })); + + // Set initial selected folder + setSelectedFolders(prev => ({ + ...prev, + [updatedAccounts[1].id]: 'INBOX' + })); + } } else { // User is authenticated but doesn't have email credentials setShowLoginNeeded(true); } } - // Auto-select the first non-All account if available - if (updatedAccounts.length > 1) { - console.log('Auto-selecting account:', updatedAccounts[1]); - setSelectedAccount(updatedAccounts[1]); - setShowFolders(true); - - // Ensure folders are visible for the selected account - setExpandedAccounts(prev => ({ - ...prev, - [updatedAccounts[1].id]: true - })); - - // Set initial selected folder - setSelectedFolders(prev => ({ - ...prev, - [updatedAccounts[1].id]: 'INBOX' - })); - } - // Preload first page of emails for faster initial rendering if (session?.user?.id) { await loadEmails();