WIP: feat: add default reminder for tasks with a due date #2360
|
@ -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)) {
|
||||
|
|
Reference in New Issue
Block a user
Below seems to be the same calculation as in the new
calculateDefaultReminderSeconds
function. We should probably combine these.Looks very similar, yes.