Don't schedule a reminder if the reminder date is in the past

This commit is contained in:
kolaente 2020-03-01 17:13:25 +01:00
parent 6d4ac2f2b6
commit fec60578ab
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -165,6 +165,12 @@ export default class TaskModel extends AbstractModel {
} }
async scheduleNotification(date) { async scheduleNotification(date) {
if(date < new Date()) {
console.debug('Date is in the past, not scheduling a notification. Date is ', date)
return
}
if (!('showTrigger' in Notification.prototype)) { if (!('showTrigger' in Notification.prototype)) {
console.debug('This browser does not support triggered notifications') console.debug('This browser does not support triggered notifications')
return return
@ -178,6 +184,7 @@ export default class TaskModel extends AbstractModel {
const registration = await navigator.serviceWorker.getRegistration() const registration = await navigator.serviceWorker.getRegistration()
if (typeof registration === 'undefined') { if (typeof registration === 'undefined') {
console.error('No service worker registration available')
return return
} }