From 94a57e7e3438a38b0c726229361fd44ef1c5f365 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 17 Jun 2021 02:18:17 -0500 Subject: [PATCH] Fix streaming notifictaions --- app/soapbox/actions/notifications.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/soapbox/actions/notifications.js b/app/soapbox/actions/notifications.js index 6a6253795..105d7b666 100644 --- a/app/soapbox/actions/notifications.js +++ b/app/soapbox/actions/notifications.js @@ -92,16 +92,20 @@ export function updateNotificationsQueue(notification, intlMessages, intlLocale, } // Desktop notifications - if (typeof window.Notification !== 'undefined' && showAlert && !filtered) { - const title = new IntlMessageFormat(intlMessages[`notification.${notification.type}`], intlLocale).format({ name: notification.account.display_name.length > 0 ? notification.account.display_name : notification.account.username }); - const body = (notification.status && notification.status.spoiler_text.length > 0) ? notification.status.spoiler_text : unescapeHTML(notification.status ? notification.status.content : ''); + try { + if (typeof window.Notification !== 'undefined' && showAlert && !filtered) { + const title = new IntlMessageFormat(intlMessages[`notification.${notification.type}`], intlLocale).format({ name: notification.account.display_name.length > 0 ? notification.account.display_name : notification.account.username }); + const body = (notification.status && notification.status.spoiler_text.length > 0) ? notification.status.spoiler_text : unescapeHTML(notification.status ? notification.status.content : ''); - const notify = new Notification(title, { body, icon: notification.account.avatar, tag: notification.id }); + const notify = new Notification(title, { body, icon: notification.account.avatar, tag: notification.id }); - notify.addEventListener('click', () => { - window.focus(); - notify.close(); - }); + notify.addEventListener('click', () => { + window.focus(); + notify.close(); + }); + } + } catch(e) { + console.warn(e); } if (playSound && !filtered) {