courrier multi account restore compose
This commit is contained in:
parent
2f53564b1a
commit
a35cf88c70
@ -582,25 +582,28 @@ 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 exact folder name from the account's folders list
|
||||
if (!account.folders.includes(folder)) {
|
||||
console.warn(`Folder ${folder} not found in account ${accountId}, defaulting to INBOX`);
|
||||
if (!account.folders.includes(baseFolder)) {
|
||||
console.warn(`Folder ${baseFolder} not found in account ${accountId}, defaulting to INBOX`);
|
||||
toast({
|
||||
title: "Folder not found",
|
||||
description: `The folder ${folder} does not exist for this account. Defaulting to INBOX.`,
|
||||
description: `The folder ${baseFolder} does not exist for this account. Defaulting to INBOX.`,
|
||||
variant: "destructive",
|
||||
});
|
||||
folder = 'INBOX'; // Default to INBOX if folder doesn't exist
|
||||
}
|
||||
|
||||
// Update selected folders state
|
||||
// Update selected folders state with the full prefixed folder name
|
||||
setSelectedFolders(prev => ({
|
||||
...prev,
|
||||
[accountId]: folder
|
||||
[accountId]: `${accountId}:${folder}`
|
||||
}));
|
||||
|
||||
// Change to the selected folder
|
||||
changeFolder(folder, accountId);
|
||||
// Change to the selected folder with account prefix
|
||||
changeFolder(`${accountId}:${folder}`, accountId);
|
||||
} else {
|
||||
// For all accounts view, use the original folder name
|
||||
changeFolder(folder, accountId);
|
||||
|
||||
@ -608,7 +608,12 @@ export async function getMailboxes(client: ImapFlow, accountId?: string): Promis
|
||||
try {
|
||||
const mailboxes = await client.list();
|
||||
|
||||
// Return the exact folder names from IMAP without any mapping
|
||||
// If we have an accountId, prefix the folder names to prevent namespace collisions
|
||||
if (accountId) {
|
||||
return mailboxes.map(mailbox => `${accountId}:${mailbox.path}`);
|
||||
}
|
||||
|
||||
// For backward compatibility, return unprefixed names when no accountId
|
||||
return mailboxes.map(mailbox => mailbox.path);
|
||||
} catch (error) {
|
||||
console.error('Error fetching mailboxes:', error);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user