fix issues with task routes

This commit is contained in:
Phillip Thelen
2026-02-03 15:46:01 +01:00
parent ff46459159
commit ac322b1925
2 changed files with 12 additions and 3 deletions
+11 -2
View File
@@ -270,7 +270,6 @@ async function getTasks (req, res, options = {}) {
remove(taskOrder, taskId => tasks.findIndex(task => task._id === taskId) === -1);
if (preLength !== taskOrder.length) {
owner.tasksOrder[key] = taskOrder;
owner.markModified('tasksOrder');
ownerDirty = true;
}
});
@@ -303,7 +302,17 @@ async function getTasks (req, res, options = {}) {
}
});
if (ownerDirty) await owner.save();
if (ownerDirty) {
let model;
if (challenge) {
model = Challenge;
} else if (group) {
model = Group;
} else {
model = User;
}
await model.updateOne({ _id: owner._id }, { tasksOrder: owner.tasksOrder }).exec();
}
// Remove empty values from the array and add any unordered task
orderedTasks = compact(orderedTasks).concat(unorderedTasks);
+1 -1
View File
@@ -82,7 +82,7 @@ export function setNextDue (task, user, dueDateOption) {
now = dateTaskIsDue;
}
const optionsForShouldDo = user.preferences.toObject();
const optionsForShouldDo = user.preferences;
optionsForShouldDo.now = now;
task.isDue = shared.shouldDo(dateTaskIsDue, task, optionsForShouldDo);