From 22f693884efae8a948b35cb63aa04c13f6efc562 Mon Sep 17 00:00:00 2001 From: alma Date: Mon, 28 Apr 2025 14:52:05 +0200 Subject: [PATCH] courrier multi account restore compose --- app/courrier/page.tsx | 17 +++++++++++++++-- hooks/use-courrier.ts | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index 8f2ca182..896b4603 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -531,8 +531,21 @@ export default function CourrierPage() { // Reset to page 1 when changing folders setPage(1); - // If we have a specific accountId, store it with the folder - if (accountId) { + // If we have a specific accountId, validate the folder exists for that account + if (accountId && accountId !== 'all-accounts') { + const account = accounts.find(a => a.id === accountId); + if (!account) { + console.error(`Account ${accountId} not found`); + return; + } + + // Check if the folder exists for this account + if (!account.folders?.includes(folder)) { + console.error(`Folder ${folder} does not exist for account ${accountId}`); + // Fall back to INBOX if the folder doesn't exist + folder = 'INBOX'; + } + // Store the current account ID with the folder change console.log(`Changing folder to ${folder} for account ${accountId}`); } diff --git a/hooks/use-courrier.ts b/hooks/use-courrier.ts index 093b5810..f258dfc3 100644 --- a/hooks/use-courrier.ts +++ b/hooks/use-courrier.ts @@ -108,6 +108,7 @@ export const useCourrier = () => { // Add accountId if provided and not 'loading-account' if (accountId && accountId !== 'all-accounts' && accountId !== 'loading-account') { queryParams.set('accountId', accountId); + console.log(`Loading emails for account ${accountId} in folder ${currentFolder}`); } // First try Redis cache with low timeout