#1416: Add relative Reminders #1427
|
@ -1517,14 +1517,20 @@ func updateRelativeReminderDates(task *Task) (err error) {
|
|||
case ReminderRelationDueDate:
|
||||
if !task.DueDate.IsZero() {
|
||||
reminder.Reminder = task.DueDate.Add(relativeDuration)
|
||||
} else {
|
||||
reminder.Reminder = time.Time{}
|
||||
konrad marked this conversation as resolved
Outdated
|
||||
}
|
||||
case ReminderRelationStartDate:
|
||||
if !task.StartDate.IsZero() {
|
||||
reminder.Reminder = task.StartDate.Add(relativeDuration)
|
||||
} else {
|
||||
ce72 marked this conversation as resolved
Outdated
konrad
commented
We should add a validation so that it's not possible to create a relative reminder without telling it what it's relative to (probably not here). We should add a validation so that it's not possible to create a relative reminder without telling it what it's relative to (probably not here).
ce72
commented
That would not break anything. There would just be a useless half-of-a-reminder (which maybe could be edited later). Where should we add a validation, if? That would not break anything. There would just be a useless half-of-a-reminder (which maybe could be edited later). Where should we add a validation, if?
konrad
commented
Since there's no dedicated endpoint just for reminders, I think right here is a good place for a validation. I think Since there's no dedicated endpoint just for reminders, I think right here is a good place for a validation. I think `updateRelativeReminderDates` is called when creating or updating a task?
ce72
commented
ok ok
|
||||
reminder.Reminder = time.Time{}
|
||||
}
|
||||
case ReminderRelationEndDate:
|
||||
if !task.EndDate.IsZero() {
|
||||
reminder.Reminder = task.EndDate.Add(relativeDuration)
|
||||
} else {
|
||||
reminder.Reminder = time.Time{}
|
||||
}
|
||||
default:
|
||||
if reminder.RelativePeriod != 0 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user
I think we can get rid of all the
else
clauses and move them before theswitch
statements so that the logic inside the switch will override the empty reminder time.Also, what should happen in case the reminder date is an empty
time.Time
? Isn't that an invalid case and should be filtered out? Or better, fail with an error message so that the user knows why it ignores the reminder?Ok. Not sure if it's better, but ok.
The current implementation permits users to enter a reminder relative to due date and set the due date after that. I don't think we should ban this use case and I don't think the api should be too restrictive here.
An empty reminder date is still valid (actually it has fired at 01.01.0001) and it may be updated to a current value, if the due_date is entered later. In any case the situation is always visible at the frontend, because inactive reminders are rendered in red. So I would strongly vote against an additional validation.
Okay, that makes a lot of sense. I didn't think of that. If we make this clear in the frontend it is fine to leave it the way it currently is.