Compare commits
No commits in common. "e5202791ac6f35a610055202f0f54419d9850c86" and "026367fb1779563957bf6b12728b1483aed71c86" have entirely different histories.
e5202791ac
...
026367fb17
24
server.js
24
server.js
|
@ -114,34 +114,16 @@ app.get('/calendar/:id', (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
//function to save CalendarData to calendars.json
|
//function to save CalendarData to calendars.json
|
||||||
function saveCalendarData(calendarId, linkGroupName, calendars) {
|
function saveCalendarData(calendarId, calendars) {
|
||||||
let calendarsData = { mergedCalendars: [] };
|
let calendarsData = { mergedCalendars: [] };
|
||||||
if (fs.existsSync(CALENDARS_FILE)) {
|
if (fs.existsSync(CALENDARS_FILE)) {
|
||||||
try {
|
calendarsData = JSON.parse(fs.readFileSync(CALENDARS_FILE, 'utf8'));
|
||||||
const fileContent = fs.readFileSync(CALENDARS_FILE, 'utf8');
|
|
||||||
if (fileContent) {
|
|
||||||
calendarsData = JSON.parse(fileContent);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error reading calendars file:', error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Ensure mergedCalendars array exists
|
|
||||||
if (!calendarsData.mergedCalendars) {
|
|
||||||
calendarsData.mergedCalendars = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
calendarsData.mergedCalendars.push({
|
calendarsData.mergedCalendars.push({
|
||||||
id: calendarId,
|
id: calendarId,
|
||||||
linkGroupName: linkGroupName,
|
|
||||||
calendars: calendars
|
calendars: calendars
|
||||||
});
|
});
|
||||||
|
fs.writeFileSync(CALENDARS_FILE, JSON.stringify(calendarsData, null, 2));
|
||||||
try {
|
|
||||||
fs.writeFileSync(CALENDARS_FILE, JSON.stringify(calendarsData, null, 2));
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error writing to calendars file:', error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to update the merged calendar
|
// Function to update the merged calendar
|
||||||
|
|
Loading…
Reference in New Issue