Merge branch 'develop' into sabrecat/teams-rebase

This commit is contained in:
SabreCat
2022-03-23 20:23:29 -05:00
63 changed files with 454 additions and 276 deletions

View File

@@ -836,6 +836,32 @@ 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 taskListQuery = { type: task.type };
if (group) {
taskListQuery['group.id'] = owner._id;
taskListQuery.userId = { $exists: false };
} else if (challenge) {
taskListQuery['challenge.id'] = owner._id;
taskListQuery.userId = { $exists: false };
} else {
taskListQuery.userId = owner._id;
}
const taskList = await Tasks.Task.find(
taskListQuery,
{ _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