Fix new tasks not getting a new task index (#116)
This commit is contained in:
parent
720df3cbed
commit
7cdc997191
2 changed files with 99 additions and 59 deletions
|
|
@ -497,6 +497,14 @@ func (t *Task) Create(a web.Auth) (err error) {
|
|||
t.UID = utils.MakeRandomString(40)
|
||||
}
|
||||
|
||||
// Get the index for this task
|
||||
latestTask := &Task{}
|
||||
_, err = x.Where("list_id = ?", t.ListID).OrderBy("id desc").Get(latestTask)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
t.Index = latestTask.Index + 1
|
||||
t.CreatedByID = u.ID
|
||||
t.CreatedBy = u
|
||||
if _, err = x.Insert(t); err != nil {
|
||||
|
|
|
|||
Reference in a new issue