mail page ui correction maj compose 20 bis 9
This commit is contained in:
parent
ba392749ce
commit
f1befb1515
@ -116,7 +116,7 @@ export async function GET() {
|
||||
const allEmails: Email[] = [];
|
||||
|
||||
imap.once('ready', () => {
|
||||
// Get all mailboxes
|
||||
// First, get all mailboxes to find the correct folder names
|
||||
imap.getBoxes((err, boxes) => {
|
||||
if (err) {
|
||||
console.error('Error getting mailboxes:', err);
|
||||
@ -125,11 +125,15 @@ export async function GET() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Define folders to check
|
||||
const foldersToCheck = ['INBOX', '[Gmail]/Sent Mail', '[Gmail]/Trash', '[Gmail]/Starred'];
|
||||
// Log available mailboxes to see their structure
|
||||
console.log('Available mailboxes:', Object.keys(boxes));
|
||||
|
||||
// For Infomaniak, common folder names are:
|
||||
const foldersToCheck = ['INBOX', 'Sent', 'Trash', 'Drafts'];
|
||||
let foldersProcessed = 0;
|
||||
|
||||
foldersToCheck.forEach(folderName => {
|
||||
const processFolder = (folderName: string) => {
|
||||
console.log(`Opening folder: ${folderName}`);
|
||||
imap.openBox(folderName, false, (err, box) => {
|
||||
if (err) {
|
||||
console.error(`Error opening ${folderName}:`, err);
|
||||
@ -140,6 +144,8 @@ export async function GET() {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Successfully opened ${folderName}, messages:`, box.messages.total);
|
||||
|
||||
if (box.messages.total === 0) {
|
||||
foldersProcessed++;
|
||||
if (foldersProcessed === foldersToCheck.length) {
|
||||
@ -164,7 +170,7 @@ export async function GET() {
|
||||
starred: false,
|
||||
body: '',
|
||||
to: '',
|
||||
folder: folderName // Add folder information
|
||||
folder: folderName
|
||||
};
|
||||
|
||||
msg.on('body', (stream, info) => {
|
||||
@ -201,26 +207,30 @@ export async function GET() {
|
||||
});
|
||||
|
||||
f.once('end', () => {
|
||||
console.log(`Finished processing ${folderName}`);
|
||||
foldersProcessed++;
|
||||
if (foldersProcessed === foldersToCheck.length) {
|
||||
finishProcessing();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function finishProcessing() {
|
||||
console.log('All folders processed, total emails:', allEmails.length);
|
||||
const response = {
|
||||
emails: allEmails,
|
||||
mailUrl: process.env.NEXTCLOUD_URL ? `${process.env.NEXTCLOUD_URL}/apps/mail/` : null
|
||||
};
|
||||
imap.end();
|
||||
resolve(NextResponse.json(response));
|
||||
}
|
||||
// Process each folder sequentially to avoid IMAP connection issues
|
||||
foldersToCheck.forEach(folder => processFolder(folder));
|
||||
});
|
||||
});
|
||||
|
||||
function finishProcessing() {
|
||||
console.log('All folders processed, total emails:', allEmails.length);
|
||||
const response = {
|
||||
emails: allEmails,
|
||||
mailUrl: process.env.NEXTCLOUD_URL ? `${process.env.NEXTCLOUD_URL}/apps/mail/` : null
|
||||
};
|
||||
imap.end();
|
||||
resolve(NextResponse.json(response));
|
||||
}
|
||||
|
||||
imap.once('error', (err) => {
|
||||
console.error('IMAP error:', err);
|
||||
resolve(NextResponse.json({
|
||||
|
||||
@ -484,9 +484,9 @@ export default function MailPage() {
|
||||
case 'starred':
|
||||
return email.starred;
|
||||
case 'sent':
|
||||
return email.folder === '[Gmail]/Sent Mail';
|
||||
return email.folder === 'Sent';
|
||||
case 'trash':
|
||||
return email.folder === '[Gmail]/Trash';
|
||||
return email.folder === 'Trash';
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user