From c734f5244433c82b73a2c9170fb7bf35de43b8d8 Mon Sep 17 00:00:00 2001 From: alma Date: Mon, 28 Apr 2025 18:08:44 +0200 Subject: [PATCH] courrier multi account restore compose --- app/courrier/page.tsx | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index c1027f58..94fcf7bd 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -591,28 +591,33 @@ export default function CourrierPage() { account.folders = ['INBOX', 'SENT', 'DRAFTS', 'TRASH']; } - // Remove account prefix if present - const baseFolder = folder.includes(':') ? folder.split(':')[1] : folder; + // Use the full prefixed folder name for existence check + const fullFolder = folder.includes(':') ? folder : `${accountId}:${folder}`; - // Use the exact folder name from the account's folders list - if (!account.folders.includes(baseFolder)) { - console.warn(`Folder ${baseFolder} not found in account ${accountId}, defaulting to INBOX`); + if (!account.folders.includes(fullFolder)) { + console.warn(`Folder ${fullFolder} not found in account ${accountId}, defaulting to INBOX`); toast({ title: "Folder not found", - description: `The folder ${baseFolder} does not exist for this account. Defaulting to INBOX.`, + description: `The folder ${fullFolder} does not exist for this account. Defaulting to INBOX.`, variant: "destructive", }); - folder = 'INBOX'; // Default to INBOX if folder doesn't exist + // Default to INBOX with prefix + setSelectedFolders(prev => ({ + ...prev, + [accountId]: `${accountId}:INBOX` + })); + changeFolder(`${accountId}:INBOX`, accountId); + return; } // Update selected folders state with the full prefixed folder name setSelectedFolders(prev => ({ ...prev, - [accountId]: `${accountId}:${folder}` + [accountId]: fullFolder })); // Change to the selected folder with account prefix - changeFolder(`${accountId}:${folder}`, accountId); + changeFolder(fullFolder, accountId); } else { // For all accounts view, use the original folder name changeFolder(folder, accountId);