mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 05:37:22 +01:00
Tasks is due (#8711)
* Added isDue field and isDue set on create * Added isDue update on update task * Add isdue calc to score task * Added isdue calc to cron * Fixed lint issue * Added isDue to no set and updated grammar
This commit is contained in:
@@ -431,6 +431,7 @@ api.updateTask = {
|
||||
} else if (task.userId !== user._id) { // If the task is owned by a user make it's the current one
|
||||
throw new NotFound(res.t('taskNotFound'));
|
||||
}
|
||||
|
||||
let oldCheckList = task.checklist;
|
||||
// we have to convert task to an object because otherwise things don't get merged correctly. Bad for performances?
|
||||
let [updatedTaskObj] = common.ops.updateTask(task.toObject(), req);
|
||||
@@ -455,6 +456,10 @@ api.updateTask = {
|
||||
task.group.approval.required = true;
|
||||
}
|
||||
|
||||
if (sanitizedObj.type === 'daily') {
|
||||
task.isDue = common.shouldDo(Date.now(), sanitizedObj, user.preferences);
|
||||
}
|
||||
|
||||
let savedTask = await task.save();
|
||||
|
||||
if (group && task.group.id && task.group.assignedUsers.length > 0) {
|
||||
@@ -584,6 +589,10 @@ api.scoreTask = {
|
||||
}
|
||||
}
|
||||
|
||||
if (task.type === 'daily') {
|
||||
task.isDue = common.shouldDo(Date.now(), task, user.preferences);
|
||||
}
|
||||
|
||||
let results = await Bluebird.all([
|
||||
user.save(),
|
||||
task.save(),
|
||||
|
||||
Reference in New Issue
Block a user