Fixed task update function not updating when marking a task as done

This commit is contained in:
kolaente 2018-09-10 07:59:45 +02:00
parent b91d9eb712
commit 8ed1fb304e
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -29,12 +29,22 @@ func (i *ListTask) Create(doer *User) (err error) {
// Update updates a list task // Update updates a list task
func (i *ListTask) Update() (err error) { func (i *ListTask) Update() (err error) {
// Check if the task exists // Check if the task exists
_, err = GetListTaskByID(i.ID) ot, err := GetListTaskByID(i.ID)
if err != nil { if err != nil {
return return
} }
// Do the update // If we dont have a text, use the one from the original task
_, err = x.ID(i.ID).Update(i) if i.Text == "" {
return err 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
}
} }