Compare commits

..

No commits in common. "e5202791ac6f35a610055202f0f54419d9850c86" and "026367fb1779563957bf6b12728b1483aed71c86" have entirely different histories.

1 changed files with 3 additions and 21 deletions

View File

@ -114,34 +114,16 @@ app.get('/calendar/:id', (req, res) => {
});
//function to save CalendarData to calendars.json
function saveCalendarData(calendarId, linkGroupName, calendars) {
function saveCalendarData(calendarId, calendars) {
let calendarsData = { mergedCalendars: [] };
if (fs.existsSync(CALENDARS_FILE)) {
try {
const fileContent = fs.readFileSync(CALENDARS_FILE, 'utf8');
if (fileContent) {
calendarsData = JSON.parse(fileContent);
}
} catch (error) {
console.error('Error reading calendars file:', error);
}
calendarsData = JSON.parse(fs.readFileSync(CALENDARS_FILE, 'utf8'));
}
// Ensure mergedCalendars array exists
if (!calendarsData.mergedCalendars) {
calendarsData.mergedCalendars = [];
}
calendarsData.mergedCalendars.push({
id: calendarId,
linkGroupName: linkGroupName,
calendars: calendars
});
try {
fs.writeFileSync(CALENDARS_FILE, JSON.stringify(calendarsData, null, 2));
} catch (error) {
console.error('Error writing to calendars file:', error);
}
fs.writeFileSync(CALENDARS_FILE, JSON.stringify(calendarsData, null, 2));
}
// Function to update the merged calendar