courrier multi account restore compose

This commit is contained in:
alma 2025-04-28 18:08:44 +02:00
parent a26c2bfa03
commit c734f52444

View File

@ -591,28 +591,33 @@ export default function CourrierPage() {
account.folders = ['INBOX', 'SENT', 'DRAFTS', 'TRASH']; account.folders = ['INBOX', 'SENT', 'DRAFTS', 'TRASH'];
} }
// Remove account prefix if present // Use the full prefixed folder name for existence check
const baseFolder = folder.includes(':') ? folder.split(':')[1] : folder; const fullFolder = folder.includes(':') ? folder : `${accountId}:${folder}`;
// Use the exact folder name from the account's folders list if (!account.folders.includes(fullFolder)) {
if (!account.folders.includes(baseFolder)) { console.warn(`Folder ${fullFolder} not found in account ${accountId}, defaulting to INBOX`);
console.warn(`Folder ${baseFolder} not found in account ${accountId}, defaulting to INBOX`);
toast({ toast({
title: "Folder not found", 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", 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 // Update selected folders state with the full prefixed folder name
setSelectedFolders(prev => ({ setSelectedFolders(prev => ({
...prev, ...prev,
[accountId]: `${accountId}:${folder}` [accountId]: fullFolder
})); }));
// Change to the selected folder with account prefix // Change to the selected folder with account prefix
changeFolder(`${accountId}:${folder}`, accountId); changeFolder(fullFolder, accountId);
} else { } else {
// For all accounts view, use the original folder name // For all accounts view, use the original folder name
changeFolder(folder, accountId); changeFolder(folder, accountId);