From 8ed1fb304ee404fca9b74bf6b28bf4ccfb4693ab Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 10 Sep 2018 07:59:45 +0200 Subject: [PATCH] Fixed task update function not updating when marking a task as done --- models/list_items_create_update.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/models/list_items_create_update.go b/models/list_items_create_update.go index 5a2d8b01..dbfba60f 100644 --- a/models/list_items_create_update.go +++ b/models/list_items_create_update.go @@ -29,12 +29,22 @@ func (i *ListTask) Create(doer *User) (err error) { // Update updates a list task func (i *ListTask) Update() (err error) { // Check if the task exists - _, err = GetListTaskByID(i.ID) + ot, err := GetListTaskByID(i.ID) if err != nil { return } - // Do the update - _, err = x.ID(i.ID).Update(i) - return err + // If we dont have a text, use the one from the original task + if i.Text == "" { + i.Text = ot.Text + } + + // For whatever reason, xorm dont detect if done is updated, so we need to update this every time by hand + if i.Done != ot.Done { + _, err = x.ID(i.ID).Cols("done").Update(i) + return + } else { + _, err = x.ID(i.ID).Update(i) + return + } }