[Glitch] Further remove old notifications code
Port e8672e27e8 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
			
			
This commit is contained in:
		
							parent
							
								
									32567a6d8d
								
							
						
					
					
						commit
						412a0dd661
					
				| 
						 | 
					@ -7,26 +7,18 @@ import { requestNotificationPermission } from '../utils/notifications';
 | 
				
			||||||
import { fetchFollowRequests } from './accounts';
 | 
					import { fetchFollowRequests } from './accounts';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  importFetchedAccount,
 | 
					  importFetchedAccount,
 | 
				
			||||||
  importFetchedStatus,
 | 
					 | 
				
			||||||
} from './importer';
 | 
					} from './importer';
 | 
				
			||||||
import { submitMarkers } from './markers';
 | 
					import { submitMarkers } from './markers';
 | 
				
			||||||
import { notificationsUpdate } from "./notifications_typed";
 | 
					import { notificationsUpdate } from "./notifications_typed";
 | 
				
			||||||
import { register as registerPushNotifications } from './push_notifications';
 | 
					import { register as registerPushNotifications } from './push_notifications';
 | 
				
			||||||
import { saveSettings } from './settings';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
export * from "./notifications_typed";
 | 
					export * from "./notifications_typed";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export const NOTIFICATIONS_FILTER_SET = 'NOTIFICATIONS_FILTER_SET';
 | 
					export const NOTIFICATIONS_FILTER_SET = 'NOTIFICATIONS_FILTER_SET';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const NOTIFICATIONS_SET_BROWSER_SUPPORT    = 'NOTIFICATIONS_SET_BROWSER_SUPPORT';
 | 
					export const NOTIFICATIONS_SET_BROWSER_SUPPORT    = 'NOTIFICATIONS_SET_BROWSER_SUPPORT';
 | 
				
			||||||
export const NOTIFICATIONS_SET_BROWSER_PERMISSION = 'NOTIFICATIONS_SET_BROWSER_PERMISSION';
 | 
					export const NOTIFICATIONS_SET_BROWSER_PERMISSION = 'NOTIFICATIONS_SET_BROWSER_PERMISSION';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const NOTIFICATION_REQUESTS_DISMISS_REQUEST = 'NOTIFICATION_REQUESTS_DISMISS_REQUEST';
 | 
					 | 
				
			||||||
export const NOTIFICATION_REQUESTS_DISMISS_SUCCESS = 'NOTIFICATION_REQUESTS_DISMISS_SUCCESS';
 | 
					 | 
				
			||||||
export const NOTIFICATION_REQUESTS_DISMISS_FAIL    = 'NOTIFICATION_REQUESTS_DISMISS_FAIL';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
defineMessages({
 | 
					defineMessages({
 | 
				
			||||||
  mention: { id: 'notification.mention', defaultMessage: '{name} mentioned you' },
 | 
					  mention: { id: 'notification.mention', defaultMessage: '{name} mentioned you' },
 | 
				
			||||||
  group: { id: 'notifications.group', defaultMessage: '{count} notifications' },
 | 
					  group: { id: 'notifications.group', defaultMessage: '{count} notifications' },
 | 
				
			||||||
| 
						 | 
					@ -34,8 +26,6 @@ defineMessages({
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function updateNotifications(notification, intlMessages, intlLocale) {
 | 
					export function updateNotifications(notification, intlMessages, intlLocale) {
 | 
				
			||||||
  return (dispatch, getState) => {
 | 
					  return (dispatch, getState) => {
 | 
				
			||||||
    const activeFilter = getState().getIn(['settings', 'notifications', 'quickFilter', 'active']);
 | 
					 | 
				
			||||||
    const showInColumn = activeFilter === 'all' ? getState().getIn(['settings', 'notifications', 'shows', notification.type], true) : activeFilter === notification.type;
 | 
					 | 
				
			||||||
    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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,24 +47,9 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dispatch(submitMarkers());
 | 
					    dispatch(submitMarkers());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (showInColumn) {
 | 
					    // `notificationsUpdate` is still used in `user_lists` and `relationships` reducers
 | 
				
			||||||
    dispatch(importFetchedAccount(notification.account));
 | 
					    dispatch(importFetchedAccount(notification.account));
 | 
				
			||||||
 | 
					 | 
				
			||||||
      if (notification.status) {
 | 
					 | 
				
			||||||
        dispatch(importFetchedStatus(notification.status));
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      if (notification.report) {
 | 
					 | 
				
			||||||
        dispatch(importFetchedAccount(notification.report.target_account));
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    dispatch(notificationsUpdate({ notification, playSound: playSound && !filtered}));
 | 
					    dispatch(notificationsUpdate({ notification, playSound: playSound && !filtered}));
 | 
				
			||||||
    } else if (playSound && !filtered) {
 | 
					 | 
				
			||||||
      dispatch({
 | 
					 | 
				
			||||||
        type: NOTIFICATIONS_UPDATE_NOOP,
 | 
					 | 
				
			||||||
        meta: { sound: 'boop' },
 | 
					 | 
				
			||||||
      });
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Desktop notifications
 | 
					    // Desktop notifications
 | 
				
			||||||
    if (typeof window.Notification !== 'undefined' && showAlert && !filtered) {
 | 
					    if (typeof window.Notification !== 'undefined' && showAlert && !filtered) {
 | 
				
			||||||
| 
						 | 
					@ -93,17 +68,6 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const noOp = () => {};
 | 
					const noOp = () => {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function setFilter (filterType) {
 | 
					 | 
				
			||||||
  return dispatch => {
 | 
					 | 
				
			||||||
    dispatch({
 | 
					 | 
				
			||||||
      type: NOTIFICATIONS_FILTER_SET,
 | 
					 | 
				
			||||||
      path: ['notifications', 'quickFilter', 'active'],
 | 
					 | 
				
			||||||
      value: filterType,
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    dispatch(saveSettings());
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Browser support
 | 
					// Browser support
 | 
				
			||||||
export function setupBrowserNotifications() {
 | 
					export function setupBrowserNotifications() {
 | 
				
			||||||
  return dispatch => {
 | 
					  return dispatch => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,10 +3,10 @@ import { defineMessages, injectIntl } from 'react-intl';
 | 
				
			||||||
import { connect } from 'react-redux';
 | 
					import { connect } from 'react-redux';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { openModal } from 'flavours/glitch/actions/modal';
 | 
					import { openModal } from 'flavours/glitch/actions/modal';
 | 
				
			||||||
import { fetchNotifications } from 'flavours/glitch/actions/notification_groups';
 | 
					import { fetchNotifications , setNotificationsFilter } from 'flavours/glitch/actions/notification_groups';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { showAlert } from '../../../actions/alerts';
 | 
					import { showAlert } from '../../../actions/alerts';
 | 
				
			||||||
import { setFilter, requestBrowserPermission } from '../../../actions/notifications';
 | 
					import { requestBrowserPermission } from '../../../actions/notifications';
 | 
				
			||||||
import { changeAlerts as changePushNotifications } from '../../../actions/push_notifications';
 | 
					import { changeAlerts as changePushNotifications } from '../../../actions/push_notifications';
 | 
				
			||||||
import { changeSetting } from '../../../actions/settings';
 | 
					import { changeSetting } from '../../../actions/settings';
 | 
				
			||||||
import ColumnSettings from '../components/column_settings';
 | 
					import ColumnSettings from '../components/column_settings';
 | 
				
			||||||
| 
						 | 
					@ -43,7 +43,7 @@ const mapDispatchToProps = (dispatch) => ({
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } else if (path[0] === 'quickFilter') {
 | 
					    } else if (path[0] === 'quickFilter') {
 | 
				
			||||||
      dispatch(changeSetting(['notifications', ...path], checked));
 | 
					      dispatch(changeSetting(['notifications', ...path], checked));
 | 
				
			||||||
      dispatch(setFilter('all'));
 | 
					      dispatch(setNotificationsFilter('all'));
 | 
				
			||||||
    } else if (path[0] === 'alerts' && checked && typeof window.Notification !== 'undefined' && Notification.permission !== 'granted') {
 | 
					    } else if (path[0] === 'alerts' && checked && typeof window.Notification !== 'undefined' && Notification.permission !== 'granted') {
 | 
				
			||||||
      if (checked && typeof window.Notification !== 'undefined' && Notification.permission !== 'granted') {
 | 
					      if (checked && typeof window.Notification !== 'undefined' && Notification.permission !== 'granted') {
 | 
				
			||||||
        dispatch(requestBrowserPermission((permission) => {
 | 
					        dispatch(requestBrowserPermission((permission) => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue