From efb1312ffe323d17c666d58e8463696174896d83 Mon Sep 17 00:00:00 2001
From: revelaction <96388231+revelaction@users.noreply.github.com>
Date: Tue, 1 Oct 2024 20:09:11 +0200
Subject: [PATCH] fix: correct typo in notification display logic and add new
category handling
---
ical/parse.go | 8 ++++++--
notify/notify.go | 9 ++++-----
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/ical/parse.go b/ical/parse.go
index 9a93604..58e6f68 100644
--- a/ical/parse.go
+++ b/ical/parse.go
@@ -199,7 +199,7 @@ func (p *Parser) buildNotification(event *ics.VEvent) notify.Notification {
// Collect all Categories properties
var categories []string
- n.ShowDates = true
+ n.ShowDate = true
for _, p := range event.Properties {
if p.IANAToken == string(ics.ComponentPropertyComment) {
@@ -207,7 +207,11 @@ func (p *Parser) buildNotification(event *ics.VEvent) notify.Notification {
}
if p.IANAToken == string(ics.ComponentPropertyCategories) {
if p.Value == NoDateCategory {
- n.ShowDates = false
+ n.ShowDate = false
+ continue
+ }
+ if p.Value == NoAlarmCategory {
+ n.ShowAlarm = false
continue
}
categories = append(categories, p.Value)
diff --git a/notify/notify.go b/notify/notify.go
index 4814f47..94394a5 100644
--- a/notify/notify.go
+++ b/notify/notify.go
@@ -9,10 +9,10 @@ const Tpl = `
{{.Summary}}
{{- end}}
-{{- if and .ShowDates .EventTime}}
+{{- if and .ShowDate .EventTime}}
📅 {{.EventTime.Format "Monday, 2006-01-02"}} {{.EventTime.Format "🕒 15:04"}} 🌍 {{.EventTimeZone}}
{{- end}}
-{{- if and .ShowDates .EventTimeConf}}
+{{- if and .ShowDate .EventTimeConf}}
📅 {{.EventTimeConf.Format "Monday, 2006-01-02"}} {{.EventTimeConf.Format "🕒 15:04"}} 🌍 {{.EventTimeZoneConf}}
{{- end}}
@@ -46,7 +46,6 @@ Attendees:
{{- if .ShowAlarm}}
{{.Source}} 🔔 {{.DurIso8601}}
{{- end}}
-
`
type Notifier interface {
@@ -99,8 +98,8 @@ type Notification struct {
Comment string
// Categories lists the categories associated with the event
Categories []string
- // ShowDates indicates whether to display the event dates in the notification
- ShowDates bool
+ // ShowDate indicates whether to display the event dates in the notification
+ ShowDate bool
// ShowAlarm indicates whether to display the alarm details in the notification
ShowAlarm bool
}