Skip to content

Commit

Permalink
Further remove old notifications code (mastodon#33465)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored Jan 6, 2025
1 parent c692f69 commit e8672e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 42 deletions.
42 changes: 3 additions & 39 deletions app/javascript/mastodon/actions/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,25 @@ 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' },
});

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

Expand All @@ -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) {
Expand All @@ -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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit e8672e2

Please sign in to comment.