Skip to content
Snippets Groups Projects
Commit dca286a1 authored by Julia Friesel's avatar Julia Friesel
Browse files

Disable notification listeners firing on app startup

parent de4d3955
No related branches found
No related tags found
No related merge requests found
...@@ -40,14 +40,16 @@ export default function setupNotifications(navigate) { ...@@ -40,14 +40,16 @@ export default function setupNotifications(navigate) {
repeatType: 'day' repeatType: 'day'
}) })
} }
}) }, false)
periodReminderObservable(reminder => { periodReminderObservable(reminder => {
Notification.cancelLocalNotifications({id: '2'}) Notification.cancelLocalNotifications({id: '2'})
if (reminder.enabled) setupPeriodReminder() if (reminder.enabled) setupPeriodReminder()
}) }, false)
getBleedingDaysSortedByDate().addListener(() => { getBleedingDaysSortedByDate().addListener((_, changes) => {
// the listener fires on setup, so we check if there were actually any changes
if (nothingChanged(changes)) return
Notification.cancelLocalNotifications({id: '2'}) Notification.cancelLocalNotifications({id: '2'})
if (periodReminderObservable.value.enabled) setupPeriodReminder() if (periodReminderObservable.value.enabled) setupPeriodReminder()
}) })
...@@ -77,4 +79,8 @@ function setupPeriodReminder() { ...@@ -77,4 +79,8 @@ function setupPeriodReminder() {
}) })
} }
} }
}
function nothingChanged(dbChanges) {
return Object.values(dbChanges).every(changeArray => changeArray.length === 0)
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment