mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
Updating daysOfMonths array when the startDate of a monthly is updated in the API - Fixes #12041 (#12399)
* Updating daily daysOfMonth array when startDate is updated and adding integration tests to test this functionality * Adding more test cases and adding semicolons to the end of lines * Only updating the monthly repetition if the daily was already set to repeat on a day of the month * fix(lint): whitespace Co-authored-by: Laurel Thomson <laurel.beth.thomson@gmai.com> Co-authored-by: Sabe Jones <sabrecat@gmail.com>
This commit is contained in:
@@ -681,6 +681,15 @@ 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
|
||||
// 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) {
|
||||
task.daysOfMonth = [moment(task.startDate).date()];
|
||||
}
|
||||
|
||||
setNextDue(task, user);
|
||||
const savedTask = await task.save();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user