]> cat aescling's git repositories - mastodon.git/commitdiff
Try to fix for browsers that don't support notifications
authorEugen Rochko <eugen@zeonfederated.com>
Mon, 21 Nov 2016 09:59:59 +0000 (10:59 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Mon, 21 Nov 2016 09:59:59 +0000 (10:59 +0100)
app/assets/javascripts/components/actions/notifications.jsx
app/assets/javascripts/components/containers/mastodon.jsx

index 97551ebf7e4fe8f78fe08db6a8f754397f7976a3..a03f88af13341047aaeb6853d2f4524d2fed23d6 100644 (file)
@@ -34,10 +34,12 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
     fetchRelatedRelationships(dispatch, [notification]);
 
     // Desktop notifications
-    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  = $('<p>').html(notification.status ? notification.status.content : '').text();
+    if (typeof window.Notification !== 'undefined') {
+      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  = $('<p>').html(notification.status ? notification.status.content : '').text();
 
-    new Notification(title, { body, icon: notification.account.avatar });
+      new Notification(title, { body, icon: notification.account.avatar });
+    }
   };
 };
 
index a8a9e365ea90c7a3274146c15518d2ae510a8cc6..3528ef81ca7d8eae90750a168cb58d4dcdfd672f 100644 (file)
@@ -88,7 +88,7 @@ const Mastodon = React.createClass({
     }
 
     // Desktop notifications
-    if (Notification.permission === 'default') {
+    if (typeof window.Notification !== 'undefined' && Notification.permission === 'default') {
       Notification.requestPermission();
     }
   },