Remove deprecated filter methods (#944)

This commit is contained in:
Nathan Bierema 2021-11-05 15:20:01 -04:00 committed by GitHub
parent 39be59eebe
commit de83aa1b45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 30 deletions

View File

@ -95,11 +95,6 @@ export interface ConfigWithExpandedMaxAge {
readonly actionsDenylist?: string | readonly string[];
readonly actionsAllowlist?: string | readonly string[];
serialize?: boolean | SerializeWithImmutable;
readonly statesFilter?: <S>(state: S, index?: number) => S;
readonly actionsFilter?: <A extends Action<unknown>>(
action: A,
id?: number
) => A;
readonly stateSanitizer?: <S>(state: S, index?: number) => S;
readonly actionSanitizer?: <A extends Action<unknown>>(
action: A,
@ -202,14 +197,7 @@ function __REDUX_DEVTOOLS_EXTENSION__<S, A extends Action<unknown>>(
const localFilter = getLocalFilter(config);
const serializeState = getSerializeParameter(config);
const serializeAction = getSerializeParameter(config);
let {
statesFilter,
actionsFilter,
stateSanitizer,
actionSanitizer,
predicate,
latency = 500,
} = config;
let { stateSanitizer, actionSanitizer, predicate, latency = 500 } = config;
// Deprecate actionsWhitelist and actionsBlacklist
if (config.actionsWhitelist) {
@ -219,16 +207,6 @@ function __REDUX_DEVTOOLS_EXTENSION__<S, A extends Action<unknown>>(
deprecateParam('actionsBlacklist', 'actionsDenylist');
}
// Deprecate statesFilter and actionsFilter
if (statesFilter) {
deprecateParam('statesFilter', 'stateSanitizer');
stateSanitizer = statesFilter; // eslint-disable-line no-param-reassign
}
if (actionsFilter) {
deprecateParam('actionsFilter', 'actionSanitizer');
actionSanitizer = actionsFilter; // eslint-disable-line no-param-reassign
}
const relayState = throttle(
(
liftedState?: LiftedState<S, A, unknown> | undefined,

View File

@ -182,7 +182,6 @@ describe('Redux enhancer', () => {
counter,
window.__REDUX_DEVTOOLS_EXTENSION__({
actionsDenylist: ['SOME_ACTION'],
statesFilter: (state) => state,
})
);
expect(typeof window.store).toBe('object');

View File

@ -20,23 +20,23 @@ export function arrToRegex(v: string | string[]) {
function filterActions(
actionsById: { [actionId: number]: PerformAction<Action<unknown>> },
actionsFilter: ((action: Action<unknown>, id: number) => Action) | undefined
actionSanitizer: ((action: Action<unknown>, id: number) => Action) | undefined
) {
if (!actionsFilter) return actionsById;
if (!actionSanitizer) return actionsById;
return mapValues(actionsById, (action, id: number) => ({
...action,
action: actionsFilter(action.action, id),
action: actionSanitizer(action.action, id),
}));
}
function filterStates(
computedStates: { state: unknown; error?: string | undefined }[],
statesFilter: (state: unknown, actionId: number) => unknown
stateSanitizer: (state: unknown, actionId: number) => unknown
) {
if (!statesFilter) return computedStates;
if (!stateSanitizer) return computedStates;
return computedStates.map((state, idx) => ({
...state,
state: statesFilter(state.state, idx),
state: stateSanitizer(state.state, idx),
}));
}