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'];
}
// 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);