Skip to content

Commit

Permalink
Add repeating to reminder - notifications TBD
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremiahvpratt committed Feb 20, 2023
1 parent 29e5838 commit 76efd43
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
45 changes: 42 additions & 3 deletions src/components/panels/HistoryRemindersPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@
outlined
dense></v-text-field>
</settings-row>
<!-- TODO: translate -->
<settings-row
title="Repeating"
sub-title="If selected, reminders will repeat beginning from when their notifications are snoozed.">
<v-simple-checkbox v-model="creatingRepeating" v-ripple class="pa-0 mr-0" />
</settings-row>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
Expand Down Expand Up @@ -182,6 +188,11 @@
outlined
dense></v-text-field>
</settings-row>
<settings-row
title="Repeating"
sub-title="If selected, reminders will repeat beginning from when their notifications are snoozed.">
<v-simple-checkbox v-model="editingRepeating" v-ripple :disabled="true" class="pa-0 mr-0" />
</settings-row>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
Expand Down Expand Up @@ -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
})
}
Expand All @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/store/gui/reminders/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 76efd43

Please sign in to comment.