Limit Local notification to 64 https://github.com/donetick/donetick/issues/506
This commit is contained in:
@@ -3,6 +3,8 @@ import { LocalNotifications } from '@capacitor/local-notifications'
|
||||
import { Preferences } from '@capacitor/preferences'
|
||||
import murmurhash from 'murmurhash'
|
||||
|
||||
const MAX_LOCAL_NOTIFICATIONS = 64
|
||||
|
||||
const getNotificationPreferences = async () => {
|
||||
const ret = await Preferences.get({ key: 'notificationPreferences' })
|
||||
return JSON.parse(ret.value)
|
||||
@@ -206,6 +208,13 @@ const scheduleChoreNotification = async (
|
||||
continue
|
||||
}
|
||||
}
|
||||
// sort from soonest to latest:
|
||||
notifications.sort((a, b) => a.schedule.at - b.schedule.at)
|
||||
|
||||
// cap it for 64 notifications for Android:
|
||||
if (notifications.length > MAX_LOCAL_NOTIFICATIONS) {
|
||||
notifications.splice(MAX_LOCAL_NOTIFICATIONS)
|
||||
}
|
||||
|
||||
LocalNotifications.schedule({
|
||||
notifications,
|
||||
|
||||
Reference in New Issue
Block a user