WIP: feat: add default reminder for tasks with a due date #2360

Draft
konrad wants to merge 17 commits from feature/add-default-reminder into main
1 changed files with 11 additions and 1 deletions
Showing only changes of commit 80cc58a45d - Show all commits

View File

@ -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))
}
}

Below seems to be the same calculation as in the new calculateDefaultReminderSeconds function. We should probably combine these.

Below seems to be the same calculation as in the new `calculateDefaultReminderSeconds` function. We should probably combine these.

Looks very similar, yes.

Looks very similar, yes.
// Make the repeating amount to seconds
let repeatAfterSeconds = 0
if (model.repeatAfter !== null && (model.repeatAfter.amount !== null || model.repeatAfter.amount !== 0)) {