Pages corrections widget

This commit is contained in:
alma 2026-01-16 17:25:46 +01:00
parent ed9dadd77a
commit b6bb7b61ad

View File

@ -228,32 +228,30 @@ export function Email() {
items: notificationItems, items: notificationItems,
}); });
// Dispatch event for Outlook-style notifications (for new emails detected by ID) // Dispatch event for Outlook-style notifications (for new emails detected by ID)
if (hasNewEmails) { if (hasNewEmails) {
// Get only the newly arrived emails (by ID comparison) // Get only the newly arrived emails (by ID comparison)
const newEmails = transformedEmails const newEmails = transformedEmails
.filter(e => newEmailIds.has(e.id) && !e.read) .filter(e => newEmailIds.has(e.id) && !e.read)
.slice(0, 5); // Limit to 5 most recent new emails .slice(0, 5); // Limit to 5 most recent new emails
if (newEmails.length > 0) {
console.log('[Email Widget] 📧 Dispatching new emails event', {
newEmailsCount: newEmails.length,
newEmailIds: Array.from(newEmailIds),
previousCount: lastUnreadCountRef.current,
currentCount: currentUnreadCount,
previousEmailIds: Array.from(lastEmailIdsRef.current),
});
if (newEmails.length > 0) { window.dispatchEvent(new CustomEvent('new-emails-detected', {
console.log('[Email Widget] 📧 Dispatching new emails event', { detail: {
newEmailsCount: newEmails.length, emails: transformedEmails,
newEmailIds: Array.from(newEmailIds), accountMap: accountMap,
previousCount, previousCount: lastUnreadCountRef.current,
currentCount: currentUnreadCount, currentCount: currentUnreadCount,
previousEmailIds: Array.from(lastEmailIdsRef.current),
});
window.dispatchEvent(new CustomEvent('new-emails-detected', {
detail: {
emails: transformedEmails,
accountMap: accountMap,
previousCount,
currentCount: currentUnreadCount,
}
}));
} }
} }));
} }
} }