Synced isdue/next due when user joins challenge (#9779)

This commit is contained in:
Keith Holliday
2018-01-12 10:16:51 -06:00
committed by GitHub
parent 0afe797bae
commit 4c7157807b
3 changed files with 12 additions and 8 deletions

View File

@@ -14,7 +14,7 @@ import shared from '../../common';
import { sendTxn as txnEmail } from '../libs/email';
import { sendNotification as sendPushNotification } from '../libs/pushNotifications';
import cwait from 'cwait';
import { syncableAttrs } from '../libs/taskManager';
import { syncableAttrs, setNextDue } from '../libs/taskManager';
const Schema = mongoose.Schema;
@@ -145,6 +145,7 @@ schema.methods.syncToUser = async function syncChallengeToUser (user) {
matchingTask.challenge = {taskId: chalTask._id, id: challenge._id, shortName: challenge.shortName};
matchingTask.userId = user._id;
user.tasksOrder[`${chalTask.type}s`].push(matchingTask._id);
setNextDue(matchingTask, user);
} else {
_.merge(matchingTask, syncableAttrs(chalTask));
// Make sure the task is in user.tasksOrder