Skip to content

Commit

Permalink
Merge pull request #37595 from ShridharGoel/notif-tags
Browse files Browse the repository at this point in the history
Show only one update available notification at a time
  • Loading branch information
arosiclair authored Mar 11, 2024
2 parents fda1b3a + 8dd0a39 commit d21bda0
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/libs/Notification/LocalNotification/BrowserNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ function canUseBrowserNotifications(): Promise<boolean> {
* @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;
Expand All @@ -57,6 +65,7 @@ function push(title: string, body = '', icon: string | ImageSourcePropType = '',
icon: String(icon),
data,
silent,
tag,
});
notificationCache[notificationID].onclick = () => {
onClick();
Expand Down Expand Up @@ -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',
);
},

/**
Expand Down

0 comments on commit d21bda0

Please sign in to comment.