From 4a3298916dda66a8d74ead1359bcd90497ef0556 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 23 Mar 2021 22:32:05 +0100 Subject: [PATCH] Fix marking a task as done & done at dates when marking it as done through a bucket --- pkg/models/tasks.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index 0222816b5..8295f64b3 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -738,7 +738,7 @@ func checkBucketLimit(s *xorm.Session, t *Task, bucket *Bucket) (err error) { func setTaskBucket(s *xorm.Session, task *Task, originalTask *Task, doCheckBucketLimit bool) (err error) { // Make sure we have a bucket var bucket *Bucket - if task.Done { + if task.Done && originalTask != nil && !originalTask.Done { bucket, err := getDoneBucketForList(s, task.ListID) if err != nil { return err @@ -777,7 +777,7 @@ func setTaskBucket(s *xorm.Session, task *Task, originalTask *Task, doCheckBucke } } - if bucket.IsDoneBucket { + if bucket.IsDoneBucket && originalTask != nil && !originalTask.Done { task.Done = true } @@ -921,9 +921,6 @@ func (t *Task) Update(s *xorm.Session, a web.Auth) (err error) { ot.Reminders[i] = r.Reminder } - // When a repeating task is marked as done, we update all deadlines and reminders and set it as undone - updateDone(&ot, t) - // Update the assignees if err := ot.updateTaskAssignees(s, t.Assignees, a); err != nil { return err @@ -959,6 +956,9 @@ func (t *Task) Update(s *xorm.Session, a web.Auth) (err error) { return err } + // When a repeating task is marked as done, we update all deadlines and reminders and set it as undone + updateDone(&ot, t) + // If the task is being moved between lists, make sure to move the bucket + index as well if t.ListID != 0 && ot.ListID != t.ListID { latestTask := &Task{}