Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
handle doubled up recurring list items (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottleedavis authored Jun 28, 2019
1 parent a954d69 commit c403345
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
50 changes: 24 additions & 26 deletions server/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,32 +140,30 @@ func (p *Plugin) categorizeOccurrences(reminders []Reminder) (
occurrences := reminder.Occurrences

if len(occurrences) > 0 {
for _, occurrence := range occurrences {
t := occurrence.Occurrence
s := occurrence.Snoozed

if !strings.HasPrefix(reminder.Target, "~") &&
reminder.Completed == p.emptyTime &&
((occurrence.Repeat == "" && t.After(time.Now().UTC())) ||
(s != p.emptyTime && s.After(time.Now().UTC()))) {
upcomingOccurrences = append(upcomingOccurrences, occurrence)
} else if !strings.HasPrefix(reminder.Target, "~") &&
occurrence.Repeat != "" && t.After(time.Now().UTC()) {
recurringOccurrences = append(recurringOccurrences, occurrence)
} else if reminder.Completed == p.emptyTime &&
t.Before(time.Now().UTC()) &&
(s == p.emptyTime || s.Before(time.Now().UTC())) {
pastOccurrences = append(pastOccurrences, occurrence)
} else if strings.HasPrefix(reminder.Target, "~") &&
reminder.Completed == p.emptyTime &&
t.After(time.Now().UTC()) {
channelOccurrences = append(channelOccurrences, occurrence)
} else if reminder.Completed != p.emptyTime {
//p.API.LogInfo("completed reminder: " + fmt.Sprintf("%v", reminder))
} else {
//p.API.LogInfo("unknown reminder: " + fmt.Sprintf("%v", reminder))
}

occurrence := occurrences[0]
t := occurrence.Occurrence
s := occurrence.Snoozed

if !strings.HasPrefix(reminder.Target, "~") &&
reminder.Completed == p.emptyTime &&
((occurrence.Repeat == "" && t.After(time.Now().UTC())) ||
(s != p.emptyTime && s.After(time.Now().UTC()))) {
upcomingOccurrences = append(upcomingOccurrences, occurrence)
} else if !strings.HasPrefix(reminder.Target, "~") &&
occurrence.Repeat != "" && t.After(time.Now().UTC()) {
recurringOccurrences = append(recurringOccurrences, occurrence)
} else if reminder.Completed == p.emptyTime &&
t.Before(time.Now().UTC()) &&
(s == p.emptyTime || s.Before(time.Now().UTC())) {
pastOccurrences = append(pastOccurrences, occurrence)
} else if strings.HasPrefix(reminder.Target, "~") &&
reminder.Completed == p.emptyTime &&
t.After(time.Now().UTC()) {
channelOccurrences = append(channelOccurrences, occurrence)
} else if reminder.Completed != p.emptyTime {
//p.API.LogInfo("completed reminder: " + fmt.Sprintf("%v", reminder))
} else {
//p.API.LogInfo("unknown reminder: " + fmt.Sprintf("%v", reminder))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/occurrence.go
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ func (p *Plugin) everyEN(when string, user *model.User) (times []time.Time, err
chronoTime = strings.Trim(dateTimeSplit[1], " ")
}

if chronoDate == T("weekday") || chronoDate == T("weekdaysgh") {
if chronoDate == T("weekday") || chronoDate == T("weekdays") {
chronoDate = T("monday") + "," + T("tuesday") + "," + T("wednesday") + "," + T("thursday") + "," + T("friday")
}
days := p.regSplit(chronoDate, "("+T("and")+")|(,)")
Expand Down

0 comments on commit c403345

Please sign in to comment.