Further remove old notifications code (#33465)
This commit is contained in:
		@@ -7,26 +7,18 @@ import { requestNotificationPermission } from '../utils/notifications';
 | 
			
		||||
import { fetchFollowRequests } from './accounts';
 | 
			
		||||
import {
 | 
			
		||||
  importFetchedAccount,
 | 
			
		||||
  importFetchedStatus,
 | 
			
		||||
} from './importer';
 | 
			
		||||
import { submitMarkers } from './markers';
 | 
			
		||||
import { notificationsUpdate } from "./notifications_typed";
 | 
			
		||||
import { register as registerPushNotifications } from './push_notifications';
 | 
			
		||||
import { saveSettings } from './settings';
 | 
			
		||||
 | 
			
		||||
export * from "./notifications_typed";
 | 
			
		||||
 | 
			
		||||
export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';
 | 
			
		||||
 | 
			
		||||
export const NOTIFICATIONS_FILTER_SET = 'NOTIFICATIONS_FILTER_SET';
 | 
			
		||||
 | 
			
		||||
export const NOTIFICATIONS_SET_BROWSER_SUPPORT    = 'NOTIFICATIONS_SET_BROWSER_SUPPORT';
 | 
			
		||||
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({
 | 
			
		||||
  mention: { id: 'notification.mention', defaultMessage: '{name} mentioned you' },
 | 
			
		||||
  group: { id: 'notifications.group', defaultMessage: '{count} notifications' },
 | 
			
		||||
@@ -34,8 +26,6 @@ defineMessages({
 | 
			
		||||
 | 
			
		||||
export function updateNotifications(notification, intlMessages, intlLocale) {
 | 
			
		||||
  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 playSound    = getState().getIn(['settings', 'notifications', 'sounds', notification.type], true);
 | 
			
		||||
 | 
			
		||||
@@ -57,24 +47,9 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
 | 
			
		||||
 | 
			
		||||
    dispatch(submitMarkers());
 | 
			
		||||
 | 
			
		||||
    if (showInColumn) {
 | 
			
		||||
      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}));
 | 
			
		||||
    } else if (playSound && !filtered) {
 | 
			
		||||
      dispatch({
 | 
			
		||||
        type: NOTIFICATIONS_UPDATE_NOOP,
 | 
			
		||||
        meta: { sound: 'boop' },
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
    // `notificationsUpdate` is still used in `user_lists` and `relationships` reducers
 | 
			
		||||
    dispatch(importFetchedAccount(notification.account));
 | 
			
		||||
    dispatch(notificationsUpdate({ notification, playSound: playSound && !filtered}));
 | 
			
		||||
 | 
			
		||||
    // Desktop notifications
 | 
			
		||||
    if (typeof window.Notification !== 'undefined' && showAlert && !filtered) {
 | 
			
		||||
@@ -93,17 +68,6 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
 | 
			
		||||
 | 
			
		||||
const noOp = () => {};
 | 
			
		||||
 | 
			
		||||
export function setFilter (filterType) {
 | 
			
		||||
  return dispatch => {
 | 
			
		||||
    dispatch({
 | 
			
		||||
      type: NOTIFICATIONS_FILTER_SET,
 | 
			
		||||
      path: ['notifications', 'quickFilter', 'active'],
 | 
			
		||||
      value: filterType,
 | 
			
		||||
    });
 | 
			
		||||
    dispatch(saveSettings());
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Browser support
 | 
			
		||||
export function setupBrowserNotifications() {
 | 
			
		||||
  return dispatch => {
 | 
			
		||||
 
 | 
			
		||||
@@ -3,10 +3,10 @@ import { defineMessages, injectIntl } from 'react-intl';
 | 
			
		||||
import { connect } from 'react-redux';
 | 
			
		||||
 | 
			
		||||
import { openModal } from 'mastodon/actions/modal';
 | 
			
		||||
import { fetchNotifications } from 'mastodon/actions/notification_groups';
 | 
			
		||||
import { fetchNotifications , setNotificationsFilter } from 'mastodon/actions/notification_groups';
 | 
			
		||||
 | 
			
		||||
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 { changeSetting } from '../../../actions/settings';
 | 
			
		||||
import ColumnSettings from '../components/column_settings';
 | 
			
		||||
@@ -43,7 +43,7 @@ const mapDispatchToProps = (dispatch) => ({
 | 
			
		||||
      }
 | 
			
		||||
    } else if (path[0] === 'quickFilter') {
 | 
			
		||||
      dispatch(changeSetting(['notifications', ...path], checked));
 | 
			
		||||
      dispatch(setFilter('all'));
 | 
			
		||||
      dispatch(setNotificationsFilter('all'));
 | 
			
		||||
    } else if (path[0] === 'alerts' && checked && typeof window.Notification !== 'undefined' && Notification.permission !== 'granted') {
 | 
			
		||||
      if (checked && typeof window.Notification !== 'undefined' && Notification.permission !== 'granted') {
 | 
			
		||||
        dispatch(requestBrowserPermission((permission) => {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user