From ee9a78a05f6e5059e0a580caaec542fc4513f124 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Fri, 1 Mar 2024 16:53:15 +0530 Subject: [PATCH] Show only one update available notification at a time --- .../LocalNotification/BrowserNotifications.ts | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/libs/Notification/LocalNotification/BrowserNotifications.ts b/src/libs/Notification/LocalNotification/BrowserNotifications.ts index 8908b91c4f42..2a0dfc1cd91a 100644 --- a/src/libs/Notification/LocalNotification/BrowserNotifications.ts +++ b/src/libs/Notification/LocalNotification/BrowserNotifications.ts @@ -44,7 +44,15 @@ function canUseBrowserNotifications(): Promise { * @param icon Path to icon * @param data extra data to attach to the notification */ -function push(title: string, body = '', icon: string | ImageSourcePropType = '', data: LocalNotificationData = {}, onClick: LocalNotificationClickHandler = () => {}, silent = false) { +function push( + title: string, + body = '', + icon: string | ImageSourcePropType = '', + data: LocalNotificationData = {}, + onClick: LocalNotificationClickHandler = () => {}, + silent = false, + tag = '', +) { canUseBrowserNotifications().then((canUseNotifications) => { if (!canUseNotifications) { return; @@ -57,6 +65,7 @@ function push(title: string, body = '', icon: string | ImageSourcePropType = '', icon: String(icon), data, silent, + tag, }); notificationCache[notificationID].onclick = () => { onClick(); @@ -124,9 +133,17 @@ export default { * Create a notification to indicate that an update is available. */ pushUpdateAvailableNotification() { - push('Update available', 'A new version of this app is available!', '', {}, () => { - AppUpdate.triggerUpdateAvailable(); - }); + push( + 'Update available', + 'A new version of this app is available!', + '', + {}, + () => { + AppUpdate.triggerUpdateAvailable(); + }, + false, + 'UpdateAvailable', + ); }, /**