aboutsummaryrefslogtreecommitdiffstats
path: root/filters/calendar
diff options
context:
space:
mode:
authorTimon Reinold <tirei+aerc@agon.one>2024-07-19 20:20:22 +0200
committerRobin Jarry <robin@jarry.cc>2024-08-04 17:48:47 +0200
commit38c4596960c3008f09c04d0c911dba66eb9537e5 (patch)
treec0036aee44ecdf8b3386c8c4ba2ceb10bb5d0be3 /filters/calendar
parenteeacf0ca2feb4c5b631e9e40f5955500fddeb73c (diff)
downloadaerc-38c4596960c3008f09c04d0c911dba66eb9537e5.tar.gz
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 <tirei+aerc@agon.one> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'filters/calendar')
-rwxr-xr-xfilters/calendar51
1 files changed, 30 insertions, 21 deletions
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)