fix(reminders): properly parse relative reminders which don't have an amount

This commit is contained in:
kolaente 2023-06-10 18:54:39 +02:00
parent 5e4eb4a728
commit 098b5fa2b1
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 7 additions and 7 deletions

View File

@ -20,15 +20,15 @@
> >
{{ formatReminder(p) }} {{ formatReminder(p) }}
</SimpleButton> </SimpleButton>
<SimpleButton <SimpleButton
@click="showFormSwitch = 'relative'" @click="showFormSwitch = 'relative'"
class="option-button" class="option-button"
:class="{'currently-active': typeof modelValue !== 'undefined' && modelValue?.relativeTo !== null && presets.find(p => p.relativePeriod === modelValue?.relativePeriod && modelValue?.relativeTo === p.relativeTo) === undefined}" :class="{'currently-active': typeof modelValue !== 'undefined' && modelValue?.relativeTo !== null && presets.find(p => p.relativePeriod === modelValue?.relativePeriod && modelValue?.relativeTo === p.relativeTo) === undefined}"
> >
{{ $t('task.reminder.custom') }} {{ $t('task.reminder.custom') }}
</SimpleButton> </SimpleButton>
<SimpleButton <SimpleButton
@click="showFormSwitch = 'absolute'" @click="showFormSwitch = 'absolute'"
class="option-button" class="option-button"
:class="{'currently-active': modelValue?.relativeTo === null}" :class="{'currently-active': modelValue?.relativeTo === null}"
> >
@ -164,10 +164,7 @@ function updateDataAndMaybeClose(toggle) {
} }
function formatReminder(reminder: TaskReminderModel) { function formatReminder(reminder: TaskReminderModel) {
const period = secondsToPeriod(reminder.relativePeriod) const period = secondsToPeriod(reminder.relativePeriod)
// TODO: 0 does not work
if (period.amount === 0) { if (period.amount === 0) {
switch (reminder.relativeTo) { switch (reminder.relativeTo) {

View File

@ -12,6 +12,9 @@ export default class TaskReminderModel extends AbstractModel<ITaskReminder> impl
super() super()
this.assignData(data) this.assignData(data)
this.reminder = parseDateOrNull(data.reminder) this.reminder = parseDateOrNull(data.reminder)
if (this.relativeTo === '') {
this.relativeTo = null
}
} }
} }