fix access to user.tasksOrder

This commit is contained in:
Matteo Pagliazzi
2016-01-14 20:55:13 +01:00
parent 5206469e90
commit 7d5a7503cb
2 changed files with 2 additions and 2 deletions

View File

@@ -838,7 +838,7 @@ api.removeTagFromTask = {
// Remove a task from (user|challenge).tasksOrder // Remove a task from (user|challenge).tasksOrder
function _removeTaskTasksOrder (userOrChallenge, taskId, taskType) { function _removeTaskTasksOrder (userOrChallenge, taskId, taskType) {
let list = userOrChallenge.tasksOrder[taskType]; let list = userOrChallenge.tasksOrder[`${taskType}s`];
let index = list.indexOf(taskId); let index = list.indexOf(taskId);
if (index !== -1) list.splice(index, 1); if (index !== -1) list.splice(index, 1);

View File

@@ -660,7 +660,7 @@ schema.methods.unlinkChallengeTasks = async function unlinkChallengeTasks (chall
tasks = tasks.map(task => { tasks = tasks.map(task => {
// Remove task from user.tasksOrder and delete them // Remove task from user.tasksOrder and delete them
if (task.type !== 'todo' || !task.completed) { if (task.type !== 'todo' || !task.completed) {
let list = user.tasksOrder[task.type]; let list = user.tasksOrder[`${task.type}s`];
let index = list.indexOf(task._id); let index = list.indexOf(task._id);
if (index !== -1) list.splice(index, 1); if (index !== -1) list.splice(index, 1);
} }