From fec60578abf40d4d2ec82cd92032e5fb01987e23 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 1 Mar 2020 17:13:25 +0100 Subject: [PATCH] Don't schedule a reminder if the reminder date is in the past --- src/models/task.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/models/task.js b/src/models/task.js index 9ceae186b..816213aa2 100644 --- a/src/models/task.js +++ b/src/models/task.js @@ -165,6 +165,12 @@ export default class TaskModel extends AbstractModel { } 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)) { console.debug('This browser does not support triggered notifications') return @@ -178,6 +184,7 @@ export default class TaskModel extends AbstractModel { const registration = await navigator.serviceWorker.getRegistration() if (typeof registration === 'undefined') { + console.error('No service worker registration available') return }