|
|
@ -10,6 +10,7 @@ import { |
|
|
|
import { defineMessages } from 'react-intl'; |
|
|
|
import { defineMessages } from 'react-intl'; |
|
|
|
|
|
|
|
|
|
|
|
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE'; |
|
|
|
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE'; |
|
|
|
|
|
|
|
export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP'; |
|
|
|
|
|
|
|
|
|
|
|
export const NOTIFICATIONS_EXPAND_REQUEST = 'NOTIFICATIONS_EXPAND_REQUEST'; |
|
|
|
export const NOTIFICATIONS_EXPAND_REQUEST = 'NOTIFICATIONS_EXPAND_REQUEST'; |
|
|
|
export const NOTIFICATIONS_EXPAND_SUCCESS = 'NOTIFICATIONS_EXPAND_SUCCESS'; |
|
|
|
export const NOTIFICATIONS_EXPAND_SUCCESS = 'NOTIFICATIONS_EXPAND_SUCCESS'; |
|
|
@ -39,10 +40,13 @@ const unescapeHTML = (html) => { |
|
|
|
|
|
|
|
|
|
|
|
export function updateNotifications(notification, intlMessages, intlLocale) { |
|
|
|
export function updateNotifications(notification, intlMessages, intlLocale) { |
|
|
|
return (dispatch, getState) => { |
|
|
|
return (dispatch, getState) => { |
|
|
|
|
|
|
|
const showInColumn = getState().getIn(['settings', 'notifications', 'shows', notification.type], true); |
|
|
|
const showAlert = getState().getIn(['settings', 'notifications', 'alerts', notification.type], true); |
|
|
|
const showAlert = getState().getIn(['settings', 'notifications', 'alerts', notification.type], true); |
|
|
|
const playSound = getState().getIn(['settings', 'notifications', 'sounds', notification.type], true); |
|
|
|
const playSound = getState().getIn(['settings', 'notifications', 'sounds', notification.type], true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (showInColumn) { |
|
|
|
dispatch(importFetchedAccount(notification.account)); |
|
|
|
dispatch(importFetchedAccount(notification.account)); |
|
|
|
|
|
|
|
|
|
|
|
if (notification.status) { |
|
|
|
if (notification.status) { |
|
|
|
dispatch(importFetchedStatus(notification.status)); |
|
|
|
dispatch(importFetchedStatus(notification.status)); |
|
|
|
} |
|
|
|
} |
|
|
@ -54,6 +58,12 @@ export function updateNotifications(notification, intlMessages, intlLocale) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
fetchRelatedRelationships(dispatch, [notification]); |
|
|
|
fetchRelatedRelationships(dispatch, [notification]); |
|
|
|
|
|
|
|
} else if (playSound) { |
|
|
|
|
|
|
|
dispatch({ |
|
|
|
|
|
|
|
type: NOTIFICATIONS_UPDATE_NOOP, |
|
|
|
|
|
|
|
meta: { sound: 'boop' }, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Desktop notifications
|
|
|
|
// Desktop notifications
|
|
|
|
if (typeof window.Notification !== 'undefined' && showAlert) { |
|
|
|
if (typeof window.Notification !== 'undefined' && showAlert) { |
|
|
@ -61,6 +71,7 @@ export function updateNotifications(notification, intlMessages, intlLocale) { |
|
|
|
const body = (notification.status && notification.status.spoiler_text.length > 0) ? notification.status.spoiler_text : unescapeHTML(notification.status ? notification.status.content : ''); |
|
|
|
const body = (notification.status && notification.status.spoiler_text.length > 0) ? notification.status.spoiler_text : unescapeHTML(notification.status ? notification.status.content : ''); |
|
|
|
|
|
|
|
|
|
|
|
const notify = new Notification(title, { body, icon: notification.account.avatar, tag: notification.id }); |
|
|
|
const notify = new Notification(title, { body, icon: notification.account.avatar, tag: notification.id }); |
|
|
|
|
|
|
|
|
|
|
|
notify.addEventListener('click', () => { |
|
|
|
notify.addEventListener('click', () => { |
|
|
|
window.focus(); |
|
|
|
window.focus(); |
|
|
|
notify.close(); |
|
|
|
notify.close(); |
|
|
|