diff --git a/website/server/controllers/api-v3/tasks.js b/website/server/controllers/api-v3/tasks.js index 646c473e10..b0d16c65b5 100644 --- a/website/server/controllers/api-v3/tasks.js +++ b/website/server/controllers/api-v3/tasks.js @@ -681,12 +681,17 @@ api.updateTask = { task.group.managerNotes = sanitizedObj.managerNotes; } - // If the task was set to repeat monthly on a day of the month, and the start date was updated, - // the task will then need to be updated to repeat on the same day of the month as the new - // start date. For example, if the start date is updated to 7/2/2020, the daily should + // If the daily task was set to repeat monthly on a day of the month, and the start date was + // updated, the task will then need to be updated to repeat on the same day of the month as the + // new start date. For example, if the start date is updated to 7/2/2020, the daily should // repeat on the 2nd day of the month. It's possible that a task can repeat monthly on a // week of the month, in which case we won't update the repetition at all. - if (task.frequency === 'monthly' && task.daysOfMonth.length && task.startDate) { + if ( + task.type === 'daily' + && task.frequency === 'monthly' + && task.daysOfMonth.length + && task.startDate + ) { task.daysOfMonth = [moment(task.startDate).date()]; } diff --git a/website/server/models/task.js b/website/server/models/task.js index b83ab726c7..ed449bdf05 100644 --- a/website/server/models/task.js +++ b/website/server/models/task.js @@ -363,9 +363,9 @@ export const DailySchema = new Schema(_.defaults({ }, streak: { $type: Number, default: 0 }, // Days of the month that the daily should repeat on - daysOfMonth: { $type: [Number], default: [] }, + daysOfMonth: { $type: [Number], default: () => [] }, // Weeks of the month that the daily should repeat on - weeksOfMonth: { $type: [Number], default: [] }, + weeksOfMonth: { $type: [Number], default: () => [] }, isDue: { $type: Boolean }, nextDue: [{ $type: String }], yesterDaily: { $type: Boolean, default: true, required: true },