Skip to content

Commit

Permalink
refactor: rename and update category constants and logic in ical parser
Browse files Browse the repository at this point in the history
  • Loading branch information
revelaction committed Oct 2, 2024
1 parent 86271a7 commit 5a90df6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 5 additions & 6 deletions ical/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"time"
)

const NoDateCategory = "show-no-date"
const NoAlarmCategory = "show-no-alarm"
const ShowNoDateCategory = "show-no-date"
const ShowAlarmCategory = "show-alarm"

type Parser struct {
notifications []notify.Notification
Expand Down Expand Up @@ -200,19 +200,18 @@ func (p *Parser) buildNotification(event *ics.VEvent) notify.Notification {
var categories []string

n.ShowDate = true
n.ShowAlarm = 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 {
if p.Value == ShowNoDateCategory {
n.ShowDate = false
continue
}
if p.Value == NoAlarmCategory {
n.ShowAlarm = false
if p.Value == ShowAlarmCategory {
n.ShowAlarm = true
continue
}
categories = append(categories, p.Value)
Expand Down
3 changes: 2 additions & 1 deletion ical/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ SUMMARY:Event with Categories
DESCRIPTION:Event with categories A, B, show-no-alarm
CATEGORIES:A
CATEGORIES:B
CATEGORIES:show-no-alarm
CATEGORIES:show-alarm
CATEGORIES:show-no-date
END:VEVENT
END:VCALENDAR
`)
Expand Down

0 comments on commit 5a90df6

Please sign in to comment.