fix: don't emit a possible null task
This commit is contained in:
parent
3970d0fd31
commit
5f5ed410df
1 changed files with 8 additions and 4 deletions
|
@ -181,15 +181,19 @@ async function addTask() {
|
||||||
try {
|
try {
|
||||||
newTaskTitle.value = ''
|
newTaskTitle.value = ''
|
||||||
await Promise.all(newTasks)
|
await Promise.all(newTasks)
|
||||||
|
|
||||||
const taskRelationService = new TaskRelationService()
|
const taskRelationService = new TaskRelationService()
|
||||||
const relations = tasksToCreate.map(async t => {
|
const relations = tasksToCreate.map(async t => {
|
||||||
const createdTask = createdTasks.find(ct => ct.title === t.title)
|
const createdTask = createdTasks.find(ct => ct.title === t.title)
|
||||||
|
if (typeof createdTask === 'undefined') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (t.parent === null) {
|
if (t.parent === null) {
|
||||||
emit('taskAdded', createdTask)
|
emit('taskAdded', createdTask)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const createdParentTask = createdTasks.find(ct => ct.title === t.parent)
|
const createdParentTask = createdTasks.find(ct => ct.title === t.parent)
|
||||||
if (typeof createdTask === 'undefined' || typeof createdParentTask === 'undefined') {
|
if (typeof createdTask === 'undefined' || typeof createdParentTask === 'undefined') {
|
||||||
return
|
return
|
||||||
|
@ -200,11 +204,11 @@ async function addTask() {
|
||||||
otherTaskId: createdParentTask.id,
|
otherTaskId: createdParentTask.id,
|
||||||
relationKind: RELATION_KIND.PARENTTASK,
|
relationKind: RELATION_KIND.PARENTTASK,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
createdTask.relatedTasks[RELATION_KIND.PARENTTASK] = [createdParentTask]
|
createdTask.relatedTasks[RELATION_KIND.PARENTTASK] = [createdParentTask]
|
||||||
// we're only emitting here so that the relation shows up in the task list
|
// we're only emitting here so that the relation shows up in the task list
|
||||||
emit('taskAdded', createdTask)
|
emit('taskAdded', createdTask)
|
||||||
|
|
||||||
return rel
|
return rel
|
||||||
})
|
})
|
||||||
await Promise.all(relations)
|
await Promise.all(relations)
|
||||||
|
|
Loading…
Reference in a new issue