Fix: Preventing adding duplicated task ID to taskOrder fix for #11385 (#11408)

* Preventing adding duplicated task ID to taskOrder object when creating new tasks

* refactor: not using Sets for taskOrderToAdd[]

* refactor: remove unnecessary checking
This commit is contained in:
cheng-shiqi
2019-11-02 02:00:21 +08:00
committed by Matteo Pagliazzi
parent 52719ac685
commit 2741721161

View File

@@ -116,7 +116,7 @@ export async function createTasks (req, res, options = {}) {
// Otherwise update the user/challenge/group
if (!taskOrderToAdd[`${taskType}s`]) taskOrderToAdd[`${taskType}s`] = [];
taskOrderToAdd[`${taskType}s`].unshift(newTask._id);
if (!owner.tasksOrder[`${taskType}s`].includes(newTask._id)) taskOrderToAdd[`${taskType}s`].unshift(newTask._id);
return newTask;
});