From 25676cff8cc7b6dc9566b528817dbed51c967d68 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Mon, 9 Feb 2026 23:14:59 -0500 Subject: [PATCH] Limit Local notification to 64 https://github.com/donetick/donetick/issues/506 --- src/views/Chores/LocalNotificationScheduler.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/views/Chores/LocalNotificationScheduler.js b/src/views/Chores/LocalNotificationScheduler.js index 12e6b89..7ca1968 100644 --- a/src/views/Chores/LocalNotificationScheduler.js +++ b/src/views/Chores/LocalNotificationScheduler.js @@ -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,