courrier multi account restore compose
This commit is contained in:
parent
6b37f0062d
commit
d683458213
@ -125,8 +125,7 @@ export default function CourrierPage() {
|
||||
|
||||
// Email accounts for the sidebar
|
||||
const [accounts, setAccounts] = useState<Account[]>([
|
||||
{ id: 'all-accounts', name: 'All', email: '', color: 'bg-gray-500' },
|
||||
{ id: 'loading-account', name: 'Loading...', email: '', color: 'bg-blue-500', folders: [] }
|
||||
{ id: 'all-accounts', name: 'All', email: '', color: 'bg-gray-500' }
|
||||
]);
|
||||
const [selectedAccount, setSelectedAccount] = useState<Account | null>(null);
|
||||
|
||||
@ -137,17 +136,16 @@ export default function CourrierPage() {
|
||||
useEffect(() => {
|
||||
console.log('Mailboxes updated:', mailboxes);
|
||||
setAccounts(prev => {
|
||||
const updated = [...prev];
|
||||
if (updated.length > 1) {
|
||||
// Only update folders, preserve other properties including ID
|
||||
if (updated[1]) {
|
||||
updated[1] = {
|
||||
...updated[1],
|
||||
folders: mailboxes
|
||||
};
|
||||
}
|
||||
console.log('Updated accounts with new mailboxes:', updated);
|
||||
// Keep the "All" account and update the actual email account
|
||||
const updated = [prev[0]]; // Keep the "All" account
|
||||
if (prev.length > 1) {
|
||||
// Update the existing email account
|
||||
updated.push({
|
||||
...prev[1],
|
||||
folders: mailboxes
|
||||
});
|
||||
}
|
||||
console.log('Updated accounts with new mailboxes:', updated);
|
||||
return updated;
|
||||
});
|
||||
}, [mailboxes]);
|
||||
@ -196,11 +194,10 @@ export default function CourrierPage() {
|
||||
if (!accounts || accounts.length === 0) {
|
||||
console.warn('Accounts array is empty, restoring defaults');
|
||||
setAccounts([
|
||||
{ id: 'all-accounts', name: 'All', email: '', color: 'bg-gray-500' },
|
||||
{ id: 'loading-account', name: 'Loading...', email: '', color: 'bg-blue-500', folders: mailboxes }
|
||||
{ id: 'all-accounts', name: 'All', email: '', color: 'bg-gray-500' }
|
||||
]);
|
||||
}
|
||||
}, [accounts, mailboxes]);
|
||||
}, [accounts]);
|
||||
|
||||
// Initialize session and start prefetching
|
||||
useEffect(() => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user