Skip to content

Commit

Permalink
fix: correct typo in notification display logic and add new category …
Browse files Browse the repository at this point in the history
…handling
  • Loading branch information
revelaction committed Oct 1, 2024
1 parent cbf6592 commit efb1312
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 6 additions & 2 deletions ical/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,19 @@ 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) {
comments = append(comments, p.Value)
}
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)
Expand Down
9 changes: 4 additions & 5 deletions notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const Tpl = `
<b>{{.Summary}}</b>
<b> </b>
{{- end}}
{{- if and .ShowDates .EventTime}}
{{- if and .ShowDate .EventTime}}
📅 <b>{{.EventTime.Format "Monday, 2006-01-02"}}</b> <b>{{.EventTime.Format "🕒 15:04"}}</b> 🌍 {{.EventTimeZone}}
{{- end}}
{{- if and .ShowDates .EventTimeConf}}
{{- if and .ShowDate .EventTimeConf}}
📅 <i>{{.EventTimeConf.Format "Monday, 2006-01-02"}}</i> <i>{{.EventTimeConf.Format "🕒 15:04"}}</i> 🌍 <i>{{.EventTimeZoneConf}}</i>
{{- end}}
Expand Down Expand Up @@ -46,7 +46,6 @@ Attendees:
{{- if .ShowAlarm}}
{{.Source}} 🔔 {{.DurIso8601}}
{{- end}}
`

type Notifier interface {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit efb1312

Please sign in to comment.