courrier multi account restore compose

This commit is contained in:
alma 2025-04-28 17:39:08 +02:00
parent f1f8a778bb
commit b17ac56b50

View File

@ -358,11 +358,13 @@ export default function CourrierPage() {
? account.folders ? account.folders
: []; : [];
// Only add folders that actually exist for this account // Keep the account prefix in folder names
const validFolders = accountFolders.filter((folder: string) => { const validFolders = accountFolders.map((folder: string) => {
// Remove any account prefix if present // If folder doesn't have account prefix, add it
const baseFolder = folder.includes(':') ? folder.split(':')[1] : folder; if (!folder.includes(':')) {
return baseFolder && baseFolder.trim() !== ''; return `${account.id}:${folder}`;
}
return folder;
}); });
updatedAccounts.push({ updatedAccounts.push({
@ -619,23 +621,24 @@ 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 // Get the account prefix from the folder name
const baseFolder = folder.includes(':') ? folder.split(':')[1] : folder; const folderAccountId = folder.includes(':') ? folder.split(':')[0] : accountId;
// Only show folders that belong to this account
if (folderAccountId !== accountId) return null;
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);
// Check if this folder belongs to this account // Get the base folder name for display
const isVisible = account?.folders?.includes(baseFolder) || false; const baseFolder = folder.includes(':') ? folder.split(':')[1] : folder;
if (!isVisible) return null;
return ( return (
<Button <Button
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(baseFolder, accountId)} onClick={() => handleMailboxChange(folder, accountId)}
> >
<div className="flex items-center w-full"> <div className="flex items-center w-full">
{getFolderIcon(baseFolder)} {getFolderIcon(baseFolder)}