From 76efd431074cbea48ce5a4d80fdd5af7dd968d62 Mon Sep 17 00:00:00 2001 From: Jeremiah Pratt Date: Mon, 20 Feb 2023 17:47:42 -0500 Subject: [PATCH] Add repeating to reminder - notifications TBD --- .../panels/HistoryRemindersPanel.vue | 45 +++++++++++++++++-- src/store/gui/reminders/types.ts | 2 + 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/components/panels/HistoryRemindersPanel.vue b/src/components/panels/HistoryRemindersPanel.vue index ef0b7db20..457146e5f 100644 --- a/src/components/panels/HistoryRemindersPanel.vue +++ b/src/components/panels/HistoryRemindersPanel.vue @@ -145,6 +145,12 @@ outlined dense> + + + + @@ -182,6 +188,11 @@ outlined dense> + + + @@ -287,8 +298,14 @@ export default class HistoryRemindersPanel extends Mixins(BaseMixin) { if (!baseReminders) return [] return baseReminders.map((reminder: GuiRemindersStateReminder) => { let tempReminder = { ...reminder } - tempReminder.remaining_print_time = - reminder.time_delta - (this.totalPrintTime - reminder.start_total_print_time) + if (reminder.snooze_timestamps.length > 0) { + tempReminder.remaining_print_time = + reminder.time_delta - + (this.totalPrintTime - reminder.snooze_timestamps[reminder.snooze_timestamps.length - 1]) + } else { + tempReminder.remaining_print_time = + reminder.time_delta - (this.totalPrintTime - reminder.start_total_print_time) + } return tempReminder }) } @@ -313,6 +330,16 @@ export default class HistoryRemindersPanel extends Mixins(BaseMixin) { this.editingReminder.time_delta = parseFloat(value) || 0 } + get editingRepeating() { + if (!this.editingReminder) return false + return this.editingReminder.repeating + } + + set editingRepeating(value: boolean) { + if (!this.editingReminder) return + this.editingReminder.repeating = value + } + get creatingDisplayName() { if (!this.creatingReminder) return '' return this.creatingReminder.name @@ -333,6 +360,16 @@ export default class HistoryRemindersPanel extends Mixins(BaseMixin) { this.creatingReminder.time_delta = parseFloat(value) || 0 } + get creatingRepeating() { + if (!this.creatingReminder) return false + return this.creatingReminder.repeating + } + + set creatingRepeating(value: boolean) { + if (!this.creatingReminder) return + this.creatingReminder.repeating = value + } + getStatusIcon(remainingPrintTime: number) { return remainingPrintTime >= 0 ? mdiClockOutline : mdiClockAlertOutline } @@ -387,7 +424,7 @@ export default class HistoryRemindersPanel extends Mixins(BaseMixin) { } repeatReminder(reminder: GuiRemindersStateReminder) { - reminder.start_total_print_time = this.totalPrintTime + reminder.snooze_timestamps = [...reminder.snooze_timestamps, this.totalPrintTime] this.$store.dispatch('gui/reminders/update', reminder) } @@ -410,6 +447,8 @@ export default class HistoryRemindersPanel extends Mixins(BaseMixin) { id: '', name: '', start_total_print_time: 0, + snooze_timestamps: [], + repeating: true, time_delta: 0, } this.isInvalidHours = true diff --git a/src/store/gui/reminders/types.ts b/src/store/gui/reminders/types.ts index 373aa73f5..7105c019b 100644 --- a/src/store/gui/reminders/types.ts +++ b/src/store/gui/reminders/types.ts @@ -9,5 +9,7 @@ export interface GuiRemindersStateReminder { name: string start_total_print_time: number time_delta: number + repeating: boolean + snooze_timestamps: number[] remaining_print_time?: number }