0
0
Fork 0

Desktop notifications

This commit is contained in:
Eugen Rochko 2016-11-21 10:24:50 +01:00
parent e616ffc5d6
commit fb48cc3b74
3 changed files with 15 additions and 6 deletions

View file

@ -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 });
};
};