Skip to content

Commit

Permalink
fix: correct comment selection logic and enable hack duration
Browse files Browse the repository at this point in the history
  • Loading branch information
revelaction committed Oct 26, 2024
1 parent a48eb93 commit 5174a9b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions ical/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,11 @@ func (p *Parser) buildNotificationImage(n notify.Notification, event *ics.VEvent

return n
}
// pickModuloProp calculates the modulo of the number of occurrences of an event
// since a fixed start time, based on the event's interval. This is used to
// sequentially select properties like COMMENT or ATTACH, ensuring that we
// cycle through them in a predictable manner rather than randomly.
// pickModuloProp calculates the modulo of the number of occurrences of an
// event since a fixed start time, based on the event's interval (only if
// RRULE). This is used to sequentially select properties like COMMENT or
// ATTACH, ensuring that we cycle through them in a predictable manner rather
// than randomly.
func pickModuloProp(eventInterval, modulo int, eventTime time.Time) int {
fixedTime := time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
duration := eventTime.Sub(fixedTime)
Expand Down Expand Up @@ -265,7 +266,7 @@ func (p *Parser) buildNotificationCommentCategories(n notify.Notification, event
}

// Select one Comment using pickModuloProp
if len(comments) > 0 {
if len(comments) > 1 {
commentIndex := pickModuloProp(et.interval, len(comments), n.EventTime)
n.Comment = comments[commentIndex]
}
Expand Down
2 changes: 1 addition & 1 deletion notify/schedule/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (s *Scheduler) Schedule(notifications []notify.Notification, tickStart time

dur := n.Time.Sub(tickStart)
slog.Info("🚦 Schedule: 🔔", "📁", filepath.Base(n.EventPath), "📌", n.Time.Format("2006-01-02 15:04:05 MST"), "🔖", dur.Truncate(1*time.Second), "durIso", n.DurIso8601, "type", n.Type, "source", n.Source, "📸", n.ImageName)
//dur = 3 * time.Second // Hack
dur = 3 * time.Second // Hack

f, err := s.getNotifyFunc(n)
if err != nil {
Expand Down

0 comments on commit 5174a9b

Please sign in to comment.