1
0
Fork 0

ensure mergedCalendars array exists

This commit is contained in:
Ryan Mwangi 2024-10-20 01:28:35 +03:00
parent 69a6718af8
commit 7dfa5875fe
1 changed files with 7 additions and 0 deletions

View File

@ -126,10 +126,17 @@ function saveCalendarData(calendarId, linkGroupName, calendars) {
console.error('Error reading calendars file:', error);
}
}
// Ensure mergedCalendars array exists
if (!calendarsData.mergedCalendars) {
calendarsData.mergedCalendars = [];
}
calendarsData.mergedCalendars.push({
id: calendarId,
linkGroupName: linkGroupName,
calendars: calendars
});
fs.writeFileSync(CALENDARS_FILE, JSON.stringify(calendarsData, null, 2));
}