diff --git a/app/agenda/page.tsx b/app/agenda/page.tsx index f5d80f4..4e12c95 100644 --- a/app/agenda/page.tsx +++ b/app/agenda/page.tsx @@ -567,15 +567,22 @@ export default async function CalendarPage() { } }); + console.log(`[AGENDA] Found ${microsoftSyncConfigs.length} Microsoft sync configs`); + // Trigger sync for Microsoft calendars that need it (async, don't wait) for (const syncConfig of microsoftSyncConfigs) { const needsSync = !syncConfig.lastSyncAt || (Date.now() - syncConfig.lastSyncAt.getTime()) / (1000 * 60) >= syncConfig.syncFrequency; + console.log(`[AGENDA] Microsoft sync config ${syncConfig.id}: lastSyncAt=${syncConfig.lastSyncAt}, needsSync=${needsSync}, syncFrequency=${syncConfig.syncFrequency}`); + if (needsSync) { + console.log(`[AGENDA] Triggering background sync for Microsoft calendar ${syncConfig.id}`); // Trigger sync in background (don't await to avoid blocking page load) import('@/lib/services/microsoft-calendar-sync').then(({ syncMicrosoftCalendar }) => { - syncMicrosoftCalendar(syncConfig.id, false).catch((error) => { + syncMicrosoftCalendar(syncConfig.id, false).then((result) => { + console.log(`[AGENDA] Microsoft sync completed:`, result); + }).catch((error) => { console.error('Background sync failed for Microsoft calendar', { calendarSyncId: syncConfig.id, error: error instanceof Error ? error.message : String(error),