Disable notification listeners firing on app startup
This commit is contained in:
@@ -40,14 +40,16 @@ export default function setupNotifications(navigate) {
|
||||
repeatType: 'day'
|
||||
})
|
||||
}
|
||||
})
|
||||
}, false)
|
||||
|
||||
periodReminderObservable(reminder => {
|
||||
Notification.cancelLocalNotifications({id: '2'})
|
||||
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'})
|
||||
if (periodReminderObservable.value.enabled) setupPeriodReminder()
|
||||
})
|
||||
@@ -77,4 +79,8 @@ function setupPeriodReminder() {
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function nothingChanged(dbChanges) {
|
||||
return Object.values(dbChanges).every(changeArray => changeArray.length === 0)
|
||||
}
|
||||
Reference in New Issue
Block a user