Agenda refactor
This commit is contained in:
parent
27cf66646e
commit
52b0b041eb
@ -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)
|
// Trigger sync for Microsoft calendars that need it (async, don't wait)
|
||||||
for (const syncConfig of microsoftSyncConfigs) {
|
for (const syncConfig of microsoftSyncConfigs) {
|
||||||
const needsSync = !syncConfig.lastSyncAt ||
|
const needsSync = !syncConfig.lastSyncAt ||
|
||||||
(Date.now() - syncConfig.lastSyncAt.getTime()) / (1000 * 60) >= syncConfig.syncFrequency;
|
(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) {
|
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)
|
// Trigger sync in background (don't await to avoid blocking page load)
|
||||||
import('@/lib/services/microsoft-calendar-sync').then(({ syncMicrosoftCalendar }) => {
|
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', {
|
console.error('Background sync failed for Microsoft calendar', {
|
||||||
calendarSyncId: syncConfig.id,
|
calendarSyncId: syncConfig.id,
|
||||||
error: error instanceof Error ? error.message : String(error),
|
error: error instanceof Error ? error.message : String(error),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user