Fix selectSettingsNotificationsExcludedTypes not being memoized properly (#31881)
This commit is contained in:
parent
6c76a7a907
commit
ca8e892c1a
@ -1,17 +1,27 @@
|
|||||||
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
import type { RootState } from 'mastodon/store';
|
import type { RootState } from 'mastodon/store';
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
|
||||||
// state.settings is not yet typed, so we disable some ESLint checks for those selectors
|
// state.settings is not yet typed, so we disable some ESLint checks for those selectors
|
||||||
export const selectSettingsNotificationsShows = (state: RootState) =>
|
export const selectSettingsNotificationsShows = createSelector(
|
||||||
state.settings.getIn(['notifications', 'shows']).toJS() as Record<
|
[
|
||||||
|
(state) =>
|
||||||
|
state.settings.getIn(['notifications', 'shows']) as Immutable.Map<
|
||||||
string,
|
string,
|
||||||
boolean
|
boolean
|
||||||
>;
|
>,
|
||||||
|
],
|
||||||
|
(shows) => shows.toJS() as Record<string, boolean>,
|
||||||
|
);
|
||||||
|
|
||||||
export const selectSettingsNotificationsExcludedTypes = (state: RootState) =>
|
export const selectSettingsNotificationsExcludedTypes = createSelector(
|
||||||
Object.entries(selectSettingsNotificationsShows(state))
|
[selectSettingsNotificationsShows],
|
||||||
|
(shows) =>
|
||||||
|
Object.entries(shows)
|
||||||
.filter(([_type, enabled]) => !enabled)
|
.filter(([_type, enabled]) => !enabled)
|
||||||
.map(([type, _enabled]) => type);
|
.map(([type, _enabled]) => type),
|
||||||
|
);
|
||||||
|
|
||||||
export const selectSettingsNotificationsQuickFilterShow = (state: RootState) =>
|
export const selectSettingsNotificationsQuickFilterShow = (state: RootState) =>
|
||||||
state.settings.getIn(['notifications', 'quickFilter', 'show']) as boolean;
|
state.settings.getIn(['notifications', 'quickFilter', 'show']) as boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user