mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
fix(tasks): self-healing for missing tasksOrder entries
This commit is contained in:
parent
5ea82fe87f
commit
fa27aa8fe7
1 changed files with 11 additions and 0 deletions
|
|
@ -838,6 +838,17 @@ api.moveTask = {
|
|||
|
||||
// In memory updates
|
||||
const order = owner.tasksOrder[`${task.type}s`];
|
||||
if (order.indexOf(task._id) === -1) { // task is missing from list, list needs repair
|
||||
const taskList = await Tasks.Task.find({ type: task.type }, { _id: 1 }).exec();
|
||||
for (const foundTask of taskList) {
|
||||
if (order.indexOf(foundTask._id) === -1) {
|
||||
order.push(foundTask._id);
|
||||
}
|
||||
}
|
||||
const fixQuery = { $set: {} };
|
||||
fixQuery.$set[`tasksOrder.${task.type}s`] = order;
|
||||
await owner.update(fixQuery).exec();
|
||||
}
|
||||
moveTask(order, task._id, to);
|
||||
|
||||
// Server updates
|
||||
|
|
|
|||
Loading…
Reference in a new issue