Fixed task update function not updating when marking a task as done
This commit is contained in:
parent
b91d9eb712
commit
8ed1fb304e
1 changed files with 14 additions and 4 deletions
|
@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue