From 38c4596960c3008f09c04d0c911dba66eb9537e5 Mon Sep 17 00:00:00 2001 From: Timon Reinold Date: Fri, 19 Jul 2024 20:20:22 +0200 Subject: calendar: hide empty attendee list Include the ATTENDEE and DETAILED LIST section in the calendar filter's output only if there are actually attendees to list. I was especially confused by the empty DETAILED LIST, as it wasn't clear which kind of detail it was supposed to list (and it also looked a bit like a heading for the description following immediately below), see e.g. the test output in filters/vectors/calendar-invite.expected. Fixes: 777bbb77e806 ("contrib: improve readability of meeting requests") Changelog-fixed: Builtin `calendar` filter shows empty attendee list. Signed-off-by: Timon Reinold Acked-by: Robin Jarry --- filters/calendar | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'filters/calendar') diff --git a/filters/calendar b/filters/calendar index aeddeadf..a808a253 100755 --- a/filters/calendar +++ b/filters/calendar @@ -175,28 +175,30 @@ BEGIN { printf fmt, "LOCATION", location if(organizer != "") printf fmt, "ORGANIZER", organizer - printf " %-14s", "ATTENDEES " - for (idx in people_attending) { - if (idx == 1){ - printf "%s,\n", people_attending[idx] + if (notEmpty(people_attending)) { + printf " %-14s", "ATTENDEES " + for (idx in people_attending) { + if (idx == 1){ + printf "%s,\n", people_attending[idx] + } + else if (idx == length(people_attending)){ + printf " %-14s%s\n", "", people_attending[idx] + } + else{ + printf " %-14s%s,\n", "", people_attending[idx] + } } - else if (idx == length(people_attending)){ - printf " %-14s%s\n", "", people_attending[idx] - } - else{ - printf " %-14s%s,\n", "", people_attending[idx] - } - } - printf "\n\n %-14s\n", "DETAILED LIST:" - for (idx in people_attending) { - printf fmt, "ATTENDEE [" idx "]", people_attending[idx] - partstat = people_partstat[idx] - if (partstat != "") { - printf fmt, "", "STATUS\t" partstat - } - rsvp = people_rsvp[idx] - if (rsvp != "") { - printf fmt, "", "RSVP\t" rsvp + printf "\n\n %-14s\n", "DETAILED LIST:" + for (idx in people_attending) { + printf fmt, "ATTENDEE [" idx "]", people_attending[idx] + partstat = people_partstat[idx] + if (partstat != "") { + printf fmt, "", "STATUS\t" partstat + } + rsvp = people_rsvp[idx] + if (rsvp != "") { + printf fmt, "", "RSVP\t" rsvp + } } } if(entry != "") @@ -205,6 +207,13 @@ BEGIN { } } +function notEmpty(array) +{ + # "length(array) > 0" isn't POSIX-comapoptible, length accepts only strings + for (idx in array) return 1; + return 0; +} + function prepare(line) { gsub($1, "", line) -- cgit