Fix todo creating on assignee change (#5435)

This commit is contained in:
Denis Bykhov 2024-04-23 18:08:30 +05:00 committed by GitHub
parent 703960d4ee
commit 77e0b4526b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -501,9 +501,21 @@ async function changeIssueAssigneeHandler (
if (issue !== undefined) {
const status = (await control.findAll(core.class.Status, { _id: issue.status }))[0]
if (status === undefined) return []
if (status.category === task.statusCategory.Active) {
if (status.category === task.statusCategory.Active || status.category === task.statusCategory.ToDo) {
const res: Tx[] = []
const todos = await control.findAll(time.class.ToDo, {
attachedTo: issue._id
})
const now = Date.now()
for (const todo of todos) {
if (todo.doneOn != null) continue
res.push(control.txFactory.createTxUpdateDoc(todo._class, todo.space, todo._id, { doneOn: now }))
}
const tx = await getCreateToDoTx(issue, newAssignee, control)
if (tx !== undefined) return [tx]
if (tx !== undefined) {
res.push(tx)
}
return res
}
}
return []