From 7dfa5875fe4eb3cd566e02d5f4c3c9cabcbab2cd Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Sun, 20 Oct 2024 01:28:35 +0300 Subject: [PATCH] ensure mergedCalendars array exists --- server.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server.js b/server.js index 82122ca..76ba87f 100644 --- a/server.js +++ b/server.js @@ -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)); }