From 3aa0425fdd3f06d4e8c0a9edc953304691ae72ee Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Wed, 4 May 2022 09:12:37 -0400 Subject: [PATCH] Preserve notifications when tapping or clearing notifications from a channel (#6209) --- app/init/push_notifications.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/init/push_notifications.ts b/app/init/push_notifications.ts index 8a64e4bbb..818af315f 100644 --- a/app/init/push_notifications.ts +++ b/app/init/push_notifications.ts @@ -80,10 +80,12 @@ class PushNotifications { NativeNotifications.removeDeliveredNotifications(ids); } + let badgeCount = notifications.length - ids.length; + const serversUrl = Object.keys(DatabaseManager.serverDatabases); const mentionPromises = serversUrl.map((url) => getTotalMentionsForServer(url)); Promise.all(mentionPromises).then((result) => { - let badgeCount = result.reduce((acc, count) => (acc + count), 0); + badgeCount += result.reduce((acc, count) => (acc + count), 0); badgeCount = badgeCount <= 0 ? 0 : badgeCount; Notifications.ios.setBadgeCount(badgeCount); });