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 9 additions and 13 deletions
Showing only changes of commit 7725de7483 - Show all commits

View File

@ -1,5 +1,12 @@
const DEFAULT_REMINDER_KEY = 'defaultReminder'
const AMOUNTS_IN_SECONDS: { [key: string]: number } = {
konrad marked this conversation as resolved
Review

Reuse type definition. E.g.

{ [type in SavedReminderSettings['type']]: number }
Reuse type definition. E.g. ```ts { [type in SavedReminderSettings['type']]: number } ```
Review

Done.

Done.
minutes: 60,
hours: 60 * 60,
days: 60 * 60 * 24,
months: 60 * 60 * 24 * 30,
}
interface DefaultReminderSettings {
enabled: boolean,
amount: number,
@ -12,18 +19,7 @@ interface SavedReminderSettings {
}
function calculateDefaultReminderSeconds(type: string, amount: number): number {
switch (type) {
case 'minutes':
return amount * 60
case 'hours':
return amount * 60 * 60
case 'days':
return amount * 60 * 60 * 24
case 'months':
return amount * 60 * 60 * 24 * 30
}
return 0
return amount * (AMOUNTS_IN_SECONDS[type] || 0)
}
export function saveDefaultReminder(enabled: boolean, type: string, amount: number) {
@ -84,6 +80,6 @@ export function getSavedReminderSettings(): SavedReminderSettings | null {
enabled: false,
}
}
return parseSavedReminderAmount(s.amount)
}