mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
Ensured group tasks are removed from places that challegnes tasks are (#8359)
* Ensured group tasks are removed from places that challegnes tasks are * Added tests for user reset and class cast
This commit is contained in:
committed by
Matteo Pagliazzi
parent
28e8ec2d2c
commit
857aa5827b
@@ -9,7 +9,10 @@ module.exports = function reset (user, tasks = []) {
|
||||
|
||||
let tasksToRemove = [];
|
||||
tasks.forEach(task => {
|
||||
if (!task.challenge || !task.challenge.id || task.challenge.broken) {
|
||||
let isNotChallengeTask = !task.challenge || !task.challenge.id || task.challenge.broken;
|
||||
let isNotGroupTask = !task.group || !task.group.id || task.group.broken;
|
||||
|
||||
if (isNotChallengeTask && isNotGroupTask) {
|
||||
tasksToRemove.push(task._id);
|
||||
let i = user.tasksOrder[`${task.type}s`].indexOf(task._id);
|
||||
if (i !== -1) user.tasksOrder[`${task.type}s`].splice(i, 1);
|
||||
|
||||
Reference in New Issue
Block a user