From fb48cc3b7400f73c01d59a038eaf7fc3020c39f4 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 21 Nov 2016 10:24:50 +0100 Subject: Desktop notifications --- app/assets/javascripts/components/actions/notifications.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'app/assets/javascripts/components/actions') 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 = $('

').html(notification.status ? notification.status.content : '').text(); + + new Notification(title, { body }); }; }; -- cgit