feat: automatically add a reminder to a task with due date but no reminders
This commit is contained in:
parent
5b4fe9176e
commit
80cc58a45d
1 changed files with 11 additions and 1 deletions
|
@ -6,6 +6,7 @@ import LabelService from './label'
|
|||
|
||||
import {formatISO} from 'date-fns'
|
||||
import {colorFromHex} from '@/helpers/color/colorFromHex'
|
||||
import {getDefaultReminderAmount} from '@/helpers/defaultReminder'
|
||||
|
||||
const parseDate = date => {
|
||||
if (date) {
|
||||
|
@ -39,7 +40,7 @@ export default class TaskService extends AbstractService<ITask> {
|
|||
}
|
||||
|
||||
processModel(updatedModel) {
|
||||
const model = { ...updatedModel }
|
||||
const model = {...updatedModel}
|
||||
|
||||
model.title = model.title?.trim()
|
||||
|
||||
|
@ -68,6 +69,15 @@ export default class TaskService extends AbstractService<ITask> {
|
|||
})
|
||||
}
|
||||
|
||||
if (model.dueDate !== null && model.reminderDates.length === 0) {
|
||||
const defaultReminder = getDefaultReminderAmount()
|
||||
if (defaultReminder !== null) {
|
||||
const dueDate = +new Date(model.dueDate)
|
||||
const reminderDate = new Date(dueDate - (defaultReminder * 1000))
|
||||
model.reminderDates.push(formatISO(reminderDate))
|
||||
}
|
||||
}
|
||||
|
||||
// Make the repeating amount to seconds
|
||||
let repeatAfterSeconds = 0
|
||||
if (model.repeatAfter !== null && (model.repeatAfter.amount !== null || model.repeatAfter.amount !== 0)) {
|
||||
|
|
Loading…
Reference in a new issue