courrier multi account
This commit is contained in:
parent
172e5b74c6
commit
a848ef6e06
@ -155,7 +155,8 @@ export async function GET() {
|
|||||||
id: account.id,
|
id: account.id,
|
||||||
email: account.email,
|
email: account.email,
|
||||||
display_name: account.display_name || account.email,
|
display_name: account.display_name || account.email,
|
||||||
color: account.color || "#0082c9"
|
color: account.color || "#0082c9",
|
||||||
|
folders: cachedSession?.mailboxes || [] // Add folders directly to each account
|
||||||
}))
|
}))
|
||||||
});
|
});
|
||||||
} catch (dbError) {
|
} catch (dbError) {
|
||||||
|
|||||||
@ -143,6 +143,14 @@ export default function CourrierPage() {
|
|||||||
console.log('Current accounts state:', accounts);
|
console.log('Current accounts state:', accounts);
|
||||||
}, [accounts]);
|
}, [accounts]);
|
||||||
|
|
||||||
|
// Debug selectedAccount state
|
||||||
|
useEffect(() => {
|
||||||
|
console.log('Selected account changed:', selectedAccount);
|
||||||
|
if (selectedAccount) {
|
||||||
|
console.log('Selected account folders:', selectedAccount.folders);
|
||||||
|
}
|
||||||
|
}, [selectedAccount]);
|
||||||
|
|
||||||
// Calculate unread count (this would be replaced with actual data in production)
|
// Calculate unread count (this would be replaced with actual data in production)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Example: counting unread emails in the inbox
|
// Example: counting unread emails in the inbox
|
||||||
@ -249,6 +257,13 @@ export default function CourrierPage() {
|
|||||||
console.log('Setting accounts:', updatedAccounts);
|
console.log('Setting accounts:', updatedAccounts);
|
||||||
setAccounts(updatedAccounts);
|
setAccounts(updatedAccounts);
|
||||||
|
|
||||||
|
// Auto-select the first non-All account if available
|
||||||
|
if (updatedAccounts.length > 1) {
|
||||||
|
console.log('Auto-selecting account:', updatedAccounts[1]);
|
||||||
|
setSelectedAccount(updatedAccounts[1]);
|
||||||
|
setShowFolders(true);
|
||||||
|
}
|
||||||
|
|
||||||
// Preload first page of emails for faster initial rendering
|
// Preload first page of emails for faster initial rendering
|
||||||
if (session?.user?.id) {
|
if (session?.user?.id) {
|
||||||
await loadEmails();
|
await loadEmails();
|
||||||
@ -741,8 +756,10 @@ export default function CourrierPage() {
|
|||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{/* Show folders for this account if it's selected and folders are shown */}
|
{/* Show folders for this account if it's selected and folders are shown
|
||||||
{selectedAccount?.id === account.id && showFolders && account.folders && (
|
OR if it's the first account and no account is selected */}
|
||||||
|
{((selectedAccount?.id === account.id && showFolders) ||
|
||||||
|
(!selectedAccount && account.id !== 0 && account.folders)) && (
|
||||||
<div className="pl-4 mt-1 mb-2 space-y-0.5 border-l border-gray-200">
|
<div className="pl-4 mt-1 mb-2 space-y-0.5 border-l border-gray-200">
|
||||||
{account.folders && account.folders.length > 0 ? (
|
{account.folders && account.folders.length > 0 ? (
|
||||||
account.folders.map((folder) => (
|
account.folders.map((folder) => (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user