#2: Remove empty fields from generated ical
All checks were successful
Jenkins Production Deployment

This commit is contained in:
Patrick Müller 2022-12-28 11:34:25 +01:00
parent fc071096d8
commit d85f9a992b
Signed by: Paddy
GPG Key ID: 37ABC11275CAABCE

View File

@ -37,11 +37,9 @@ const serializeIcalEvent = (icalevent: iCalEvent): string => {
returnString += 'DTSTART;TZID=Europe/Berlin:' + icalevent.start; returnString += 'DTSTART;TZID=Europe/Berlin:' + icalevent.start;
returnString += 'DTEND;TZID=Europe/Berlin:' + icalevent.end; returnString += 'DTEND;TZID=Europe/Berlin:' + icalevent.end;
returnString += 'SUMMARY:' + icalevent.summary; returnString += 'SUMMARY:' + icalevent.summary;
returnString += 'DESCRIPTION:' + icalevent.description; if(!isNullOrBlank(icalevent.description)) returnString += 'DESCRIPTION:' + icalevent.description;
returnString += 'LOCATION:' + icalevent.location; if(!isNullOrBlank(icalevent.location)) returnString += 'LOCATION:' + icalevent.location;
if(!isNullOrBlank(icalevent.url)) { if(!isNullOrBlank(icalevent.url)) returnString += 'URL:' + icalevent.url;
returnString += 'URL:' + icalevent.url;
}
returnString += icalevent.footer; returnString += icalevent.footer;
return returnString; return returnString;
@ -84,6 +82,8 @@ const addEventToFile = (ical: iCalFile, event: Event) => {
}; };
const createIcalEvent = (event: Event): iCalEvent => { const createIcalEvent = (event: Event): iCalEvent => {
let description = event.description ? event.description + '\n' : '';
let location = event.location ? event.location + '\n' : '';
let url = event.url ? event.url + '\n' : ''; let url = event.url ? event.url + '\n' : '';
return { return {
@ -94,8 +94,8 @@ const createIcalEvent = (event: Event): iCalEvent => {
start: formatDate(event.startDateTime) + '\n', start: formatDate(event.startDateTime) + '\n',
end: formatDate(event.endDateTime) + '\n', end: formatDate(event.endDateTime) + '\n',
summary: event.name + '\n', summary: event.name + '\n',
description: event.description + '\n', description: description,
location: event.location + '\n', location: location,
url: url, url: url,
footer: 'END:VEVENT\n' footer: 'END:VEVENT\n'
}; };