Enable grouped notifications unconditionally (#31929)
This commit is contained in:
		
							parent
							
								
									e0648a916a
								
							
						
					
					
						commit
						c620452fd7
					
				@ -2,7 +2,6 @@ import { debounce } from 'lodash';
 | 
			
		||||
 | 
			
		||||
import type { MarkerJSON } from 'mastodon/api_types/markers';
 | 
			
		||||
import { getAccessToken } from 'mastodon/initial_state';
 | 
			
		||||
import { selectUseGroupedNotifications } from 'mastodon/selectors/settings';
 | 
			
		||||
import type { AppDispatch, RootState } from 'mastodon/store';
 | 
			
		||||
import { createAppAsyncThunk } from 'mastodon/store/typed_functions';
 | 
			
		||||
 | 
			
		||||
@ -76,12 +75,7 @@ interface MarkerParam {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getLastNotificationId(state: RootState): string | undefined {
 | 
			
		||||
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
 | 
			
		||||
  return selectUseGroupedNotifications(state)
 | 
			
		||||
    ? state.notificationGroups.lastReadId
 | 
			
		||||
    : // @ts-expect-error state.notifications is not yet typed
 | 
			
		||||
      // eslint-disable-next-line @typescript-eslint/no-unsafe-call
 | 
			
		||||
      state.getIn(['notifications', 'lastReadId']);
 | 
			
		||||
  return state.notificationGroups.lastReadId;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const buildPostMarkersParams = (state: RootState) => {
 | 
			
		||||
 | 
			
		||||
@ -1,14 +1,10 @@
 | 
			
		||||
import { selectUseGroupedNotifications } from 'mastodon/selectors/settings';
 | 
			
		||||
import { createAppAsyncThunk } from 'mastodon/store';
 | 
			
		||||
 | 
			
		||||
import { fetchNotifications } from './notification_groups';
 | 
			
		||||
import { expandNotifications } from './notifications';
 | 
			
		||||
 | 
			
		||||
export const initializeNotifications = createAppAsyncThunk(
 | 
			
		||||
  'notifications/initialize',
 | 
			
		||||
  (_, { dispatch, getState }) => {
 | 
			
		||||
    if (selectUseGroupedNotifications(getState()))
 | 
			
		||||
  (_, { dispatch }) => {
 | 
			
		||||
    void dispatch(fetchNotifications());
 | 
			
		||||
    else void dispatch(expandNotifications({}));
 | 
			
		||||
  },
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,5 @@
 | 
			
		||||
// @ts-check
 | 
			
		||||
 | 
			
		||||
import { selectUseGroupedNotifications } from 'mastodon/selectors/settings';
 | 
			
		||||
 | 
			
		||||
import { getLocale } from '../locales';
 | 
			
		||||
import { connectStream } from '../stream';
 | 
			
		||||
 | 
			
		||||
@ -105,18 +103,14 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
 | 
			
		||||
          const notificationJSON = JSON.parse(data.payload);
 | 
			
		||||
          dispatch(updateNotifications(notificationJSON, messages, locale));
 | 
			
		||||
          // TODO: remove this once the groups feature replaces the previous one
 | 
			
		||||
          if(selectUseGroupedNotifications(getState())) {
 | 
			
		||||
          dispatch(processNewNotificationForGroups(notificationJSON));
 | 
			
		||||
          }
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
        case 'notifications_merged':
 | 
			
		||||
          const state = getState();
 | 
			
		||||
          if (state.notifications.top || !state.notifications.mounted)
 | 
			
		||||
            dispatch(expandNotifications({ forceLoad: true, maxId: undefined }));
 | 
			
		||||
          if (selectUseGroupedNotifications(state)) {
 | 
			
		||||
          dispatch(refreshStaleNotificationGroups());
 | 
			
		||||
          }
 | 
			
		||||
          break;
 | 
			
		||||
        case 'conversation':
 | 
			
		||||
          // @ts-expect-error
 | 
			
		||||
@ -141,22 +135,16 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @param {Function} dispatch
 | 
			
		||||
 * @param {Function} getState
 | 
			
		||||
 */
 | 
			
		||||
async function refreshHomeTimelineAndNotification(dispatch, getState) {
 | 
			
		||||
async function refreshHomeTimelineAndNotification(dispatch) {
 | 
			
		||||
  await dispatch(expandHomeTimeline({ maxId: undefined }));
 | 
			
		||||
 | 
			
		||||
  // TODO: remove this once the groups feature replaces the previous one
 | 
			
		||||
  if(selectUseGroupedNotifications(getState())) {
 | 
			
		||||
  // TODO: polling for merged notifications
 | 
			
		||||
  try {
 | 
			
		||||
    await dispatch(pollRecentGroupNotifications());
 | 
			
		||||
  } catch {
 | 
			
		||||
    // TODO
 | 
			
		||||
  }
 | 
			
		||||
  } else {
 | 
			
		||||
    await dispatch(expandNotifications({}));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  await dispatch(fetchAnnouncements());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,6 @@ import { FormattedMessage } from 'react-intl';
 | 
			
		||||
import ImmutablePropTypes from 'react-immutable-proptypes';
 | 
			
		||||
 | 
			
		||||
import { identityContextPropShape, withIdentity } from 'mastodon/identity_context';
 | 
			
		||||
import { forceGroupedNotifications } from 'mastodon/initial_state';
 | 
			
		||||
import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_REPORTS } from 'mastodon/permissions';
 | 
			
		||||
 | 
			
		||||
import ClearColumnButton from './clear_column_button';
 | 
			
		||||
@ -36,7 +35,6 @@ class ColumnSettings extends PureComponent {
 | 
			
		||||
 | 
			
		||||
    const filterAdvancedStr = <FormattedMessage id='notifications.column_settings.filter_bar.advanced' defaultMessage='Display all categories' />;
 | 
			
		||||
    const unreadMarkersShowStr = <FormattedMessage id='notifications.column_settings.unread_notifications.highlight' defaultMessage='Highlight unread notifications' />;
 | 
			
		||||
    const groupingShowStr = <FormattedMessage id='notifications.column_settings.beta.grouping' defaultMessage='Group notifications' />;
 | 
			
		||||
    const alertStr = <FormattedMessage id='notifications.column_settings.alert' defaultMessage='Desktop notifications' />;
 | 
			
		||||
    const showStr = <FormattedMessage id='notifications.column_settings.show' defaultMessage='Show in column' />;
 | 
			
		||||
    const soundStr = <FormattedMessage id='notifications.column_settings.sound' defaultMessage='Play sound' />;
 | 
			
		||||
@ -68,18 +66,6 @@ class ColumnSettings extends PureComponent {
 | 
			
		||||
 | 
			
		||||
        <PolicyControls />
 | 
			
		||||
 | 
			
		||||
        {!forceGroupedNotifications && (
 | 
			
		||||
          <section role='group' aria-labelledby='notifications-beta'>
 | 
			
		||||
            <h3 id='notifications-beta'>
 | 
			
		||||
              <FormattedMessage id='notifications.column_settings.beta.category' defaultMessage='Experimental features' />
 | 
			
		||||
            </h3>
 | 
			
		||||
 | 
			
		||||
            <div className='column-settings__row'>
 | 
			
		||||
              <SettingToggle id='unread-notification-markers' prefix='notifications' settings={settings} settingPath={['groupingBeta']} onChange={onChange} label={groupingShowStr} />
 | 
			
		||||
            </div>
 | 
			
		||||
          </section>
 | 
			
		||||
        )}
 | 
			
		||||
 | 
			
		||||
        <section role='group' aria-labelledby='notifications-unread-markers'>
 | 
			
		||||
          <h3 id='notifications-unread-markers'>
 | 
			
		||||
            <FormattedMessage id='notifications.column_settings.unread_notifications.category' defaultMessage='Unread notifications' />
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,8 @@
 | 
			
		||||
import Notifications from 'mastodon/features/notifications';
 | 
			
		||||
import Notifications_v2 from 'mastodon/features/notifications_v2';
 | 
			
		||||
import { selectUseGroupedNotifications } from 'mastodon/selectors/settings';
 | 
			
		||||
import { useAppSelector } from 'mastodon/store';
 | 
			
		||||
 | 
			
		||||
export const NotificationsWrapper = (props) => {
 | 
			
		||||
  const optedInGroupedNotifications = useAppSelector(selectUseGroupedNotifications);
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    optedInGroupedNotifications ? <Notifications_v2 {...props} /> : <Notifications {...props} />
 | 
			
		||||
    <Notifications_v2 {...props} />
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -37,7 +37,6 @@ import { timelinePreview, trendsEnabled } from 'mastodon/initial_state';
 | 
			
		||||
import { transientSingleColumn } from 'mastodon/is_mobile';
 | 
			
		||||
import { canManageReports, canViewAdminDashboard } from 'mastodon/permissions';
 | 
			
		||||
import { selectUnreadNotificationGroupsCount } from 'mastodon/selectors/notifications';
 | 
			
		||||
import { selectUseGroupedNotifications } from 'mastodon/selectors/settings';
 | 
			
		||||
 | 
			
		||||
import ColumnLink from './column_link';
 | 
			
		||||
import DisabledAccountBanner from './disabled_account_banner';
 | 
			
		||||
@ -65,19 +64,17 @@ const messages = defineMessages({
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const NotificationsLink = () => {
 | 
			
		||||
  const optedInGroupedNotifications = useSelector(selectUseGroupedNotifications);
 | 
			
		||||
  const count = useSelector(state => state.getIn(['notifications', 'unread']));
 | 
			
		||||
  const intl = useIntl();
 | 
			
		||||
 | 
			
		||||
  const newCount = useSelector(selectUnreadNotificationGroupsCount);
 | 
			
		||||
  const count = useSelector(selectUnreadNotificationGroupsCount);
 | 
			
		||||
  const intl = useIntl();
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    <ColumnLink
 | 
			
		||||
      key='notifications'
 | 
			
		||||
      transparent
 | 
			
		||||
      to='/notifications'
 | 
			
		||||
      icon={<IconWithBadge id='bell' icon={NotificationsIcon} count={optedInGroupedNotifications ? newCount : count} className='column-link__icon' />}
 | 
			
		||||
      activeIcon={<IconWithBadge id='bell' icon={NotificationsActiveIcon} count={optedInGroupedNotifications ? newCount : count} className='column-link__icon' />}
 | 
			
		||||
      icon={<IconWithBadge id='bell' icon={NotificationsIcon} count={count} className='column-link__icon' />}
 | 
			
		||||
      activeIcon={<IconWithBadge id='bell' icon={NotificationsActiveIcon} count={count} className='column-link__icon' />}
 | 
			
		||||
      text={intl.formatMessage(messages.notifications)}
 | 
			
		||||
    />
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
@ -43,7 +43,6 @@
 | 
			
		||||
 * @property {boolean=} use_pending_items
 | 
			
		||||
 * @property {string} version
 | 
			
		||||
 * @property {string} sso_redirect
 | 
			
		||||
 * @property {boolean} force_grouped_notifications
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@ -119,7 +118,6 @@ export const criticalUpdatesPending = initialState?.critical_updates_pending;
 | 
			
		||||
// @ts-expect-error
 | 
			
		||||
export const statusPageUrl = getMeta('status_page_url');
 | 
			
		||||
export const sso_redirect = getMeta('sso_redirect');
 | 
			
		||||
export const forceGroupedNotifications = getMeta('force_grouped_notifications');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @returns {string | undefined}
 | 
			
		||||
 | 
			
		||||
@ -559,8 +559,6 @@
 | 
			
		||||
  "notifications.column_settings.admin.report": "New reports:",
 | 
			
		||||
  "notifications.column_settings.admin.sign_up": "New sign-ups:",
 | 
			
		||||
  "notifications.column_settings.alert": "Desktop notifications",
 | 
			
		||||
  "notifications.column_settings.beta.category": "Experimental features",
 | 
			
		||||
  "notifications.column_settings.beta.grouping": "Group notifications",
 | 
			
		||||
  "notifications.column_settings.favourite": "Favorites:",
 | 
			
		||||
  "notifications.column_settings.filter_bar.advanced": "Display all categories",
 | 
			
		||||
  "notifications.column_settings.filter_bar.category": "Quick filter bar",
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,3 @@
 | 
			
		||||
import { forceGroupedNotifications } from 'mastodon/initial_state';
 | 
			
		||||
import type { RootState } from 'mastodon/store';
 | 
			
		||||
 | 
			
		||||
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
 | 
			
		||||
@ -26,10 +25,6 @@ export const selectSettingsNotificationsQuickFilterAdvanced = (
 | 
			
		||||
) =>
 | 
			
		||||
  state.settings.getIn(['notifications', 'quickFilter', 'advanced']) as boolean;
 | 
			
		||||
 | 
			
		||||
export const selectUseGroupedNotifications = (state: RootState) =>
 | 
			
		||||
  forceGroupedNotifications ||
 | 
			
		||||
  (state.settings.getIn(['notifications', 'groupingBeta']) as boolean);
 | 
			
		||||
 | 
			
		||||
export const selectSettingsNotificationsShowUnread = (state: RootState) =>
 | 
			
		||||
  state.settings.getIn(['notifications', 'showUnread']) as boolean;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -109,7 +109,6 @@ class InitialStateSerializer < ActiveModel::Serializer
 | 
			
		||||
      trends_as_landing_page: Setting.trends_as_landing_page,
 | 
			
		||||
      trends_enabled: Setting.trends,
 | 
			
		||||
      version: instance_presenter.version,
 | 
			
		||||
      force_grouped_notifications: ENV['FORCE_GROUPED_NOTIFICATIONS'] == 'true',
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user