Fix task due date update not persisting for tasks with completions
When a user explicitly edited a task's due date, the backend was only updating NextDueDate if the task had no completions. For recurring tasks with completions, this caused the UI to show stale NextDueDate values since effectiveDueDate prioritizes NextDueDate over DueDate. Now always updates NextDueDate when user explicitly edits due date. Completion logic will still recalculate NextDueDate when task is completed. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -251,11 +251,10 @@ func (s *TaskService) UpdateTask(taskID, userID uint, req *requests.UpdateTaskRe
|
||||
if req.DueDate != nil {
|
||||
newDueDate := req.DueDate.ToTimePtr()
|
||||
task.DueDate = newDueDate
|
||||
// Also update NextDueDate if the task doesn't have completions yet
|
||||
// (if it has completions, NextDueDate should be managed by completion logic)
|
||||
if len(task.Completions) == 0 {
|
||||
task.NextDueDate = newDueDate
|
||||
}
|
||||
// Always update NextDueDate when user explicitly edits due date.
|
||||
// Completion logic will recalculate NextDueDate when task is completed,
|
||||
// but manual edits should take precedence.
|
||||
task.NextDueDate = newDueDate
|
||||
}
|
||||
if req.EstimatedCost != nil {
|
||||
task.EstimatedCost = req.EstimatedCost
|
||||
|
||||
Reference in New Issue
Block a user