courrier multi account restore compose

This commit is contained in:
alma 2025-04-28 17:31:31 +02:00
parent cc4201df4d
commit f1f8a778bb

View File

@ -358,17 +358,24 @@ export default function CourrierPage() {
? account.folders ? account.folders
: []; : [];
// Only add folders that actually exist for this account
const validFolders = accountFolders.filter((folder: string) => {
// Remove any account prefix if present
const baseFolder = folder.includes(':') ? folder.split(':')[1] : folder;
return baseFolder && baseFolder.trim() !== '';
});
updatedAccounts.push({ updatedAccounts.push({
id: account.id, id: account.id,
name: account.display_name || account.email, name: account.display_name || account.email,
email: account.email, email: account.email,
color: account.color || 'bg-blue-500', color: account.color || 'bg-blue-500',
folders: accountFolders folders: validFolders
}); });
console.log(`[DEBUG] Added account with folders:`, { console.log(`[DEBUG] Added account with folders:`, {
id: account.id, id: account.id,
email: account.email, email: account.email,
folders: accountFolders folders: validFolders
}); });
}); });
} else { } else {
@ -612,9 +619,14 @@ export default function CourrierPage() {
// Update the folder button rendering to show selected state based on account // Update the folder button rendering to show selected state based on account
const renderFolderButton = (folder: string, accountId: string) => { const renderFolderButton = (folder: string, accountId: string) => {
// Remove account prefix from folder name for comparison
const baseFolder = folder.includes(':') ? folder.split(':')[1] : folder;
const isSelected = selectedFolders[accountId] === folder; const isSelected = selectedFolders[accountId] === folder;
const account = accounts.find(a => a.id === accountId); const account = accounts.find(a => a.id === accountId);
const isVisible = account?.folders?.includes(folder) || false;
// Check if this folder belongs to this account
const isVisible = account?.folders?.includes(baseFolder) || false;
if (!isVisible) return null; if (!isVisible) return null;
@ -623,12 +635,12 @@ export default function CourrierPage() {
key={folder} key={folder}
variant="ghost" variant="ghost"
className={`w-full justify-start text-xs py-1 h-7 ${isSelected ? 'bg-gray-100' : ''}`} className={`w-full justify-start text-xs py-1 h-7 ${isSelected ? 'bg-gray-100' : ''}`}
onClick={() => handleMailboxChange(folder, accountId)} onClick={() => handleMailboxChange(baseFolder, accountId)}
> >
<div className="flex items-center w-full"> <div className="flex items-center w-full">
{getFolderIcon(folder)} {getFolderIcon(baseFolder)}
<span className="ml-2 truncate text-gray-700">{formatFolderName(folder)}</span> <span className="ml-2 truncate text-gray-700">{formatFolderName(baseFolder)}</span>
{folder === 'INBOX' && unreadCount > 0 && ( {baseFolder === 'INBOX' && unreadCount > 0 && (
<span className="ml-auto bg-blue-500 text-white text-[10px] px-1.5 rounded-full"> <span className="ml-auto bg-blue-500 text-white text-[10px] px-1.5 rounded-full">
{unreadCount} {unreadCount}
</span> </span>