about summary refs log tree commit diff
path: root/app/assets/javascripts/components/actions/notifications.jsx
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-21 10:24:50 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-21 10:24:50 +0100
commitfb48cc3b7400f73c01d59a038eaf7fc3020c39f4 (patch)
tree8c438fdf1cfc61a7292115b7787b46b9280a5d1b /app/assets/javascripts/components/actions/notifications.jsx
parente616ffc5d60acafb67dadf90e396226d408d0cda (diff)
Desktop notifications
Diffstat (limited to 'app/assets/javascripts/components/actions/notifications.jsx')
-rw-r--r--app/assets/javascripts/components/actions/notifications.jsx9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/assets/javascripts/components/actions/notifications.jsx b/app/assets/javascripts/components/actions/notifications.jsx
index 7863d9683..b34fc7289 100644
--- a/app/assets/javascripts/components/actions/notifications.jsx
+++ b/app/assets/javascripts/components/actions/notifications.jsx
@@ -1,5 +1,6 @@
 import api, { getLinks } from '../api'
 import Immutable from 'immutable';
+import IntlMessageFormat from 'intl-messageformat';
 
 import { fetchRelationships } from './accounts';
 
@@ -21,7 +22,7 @@ const fetchRelatedRelationships = (dispatch, notifications) => {
   }
 };
 
-export function updateNotifications(notification) {
+export function updateNotifications(notification, intlMessages, intlLocale) {
   return dispatch => {
     dispatch({
       type: NOTIFICATIONS_UPDATE,
@@ -31,6 +32,12 @@ export function updateNotifications(notification) {
     });
 
     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();
+
+    new Notification(title, { body });
   };
 };