Browse Source

Try to fix for browsers that don't support notifications

closed-social-glitch-2
Eugen Rochko 7 years ago
parent
commit
e3665c1d67
2 changed files with 6 additions and 4 deletions
  1. +5
    -3
      app/assets/javascripts/components/actions/notifications.jsx
  2. +1
    -1
      app/assets/javascripts/components/containers/mastodon.jsx

+ 5
- 3
app/assets/javascripts/components/actions/notifications.jsx View 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 });
}
};
};

+ 1
- 1
app/assets/javascripts/components/containers/mastodon.jsx View 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();
}
},

Loading…
Cancel
Save