From de83aa1b45cf8baa8245e1b99df126b15168b80d Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Fri, 5 Nov 2021 15:20:01 -0400 Subject: [PATCH] Remove deprecated filter methods (#944) --- .../browser/extension/inject/pageScript.ts | 24 +------------------ extension/test/app/inject/enhancer.spec.js | 1 - packages/redux-devtools-utils/src/filters.ts | 12 +++++----- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/extension/src/browser/extension/inject/pageScript.ts b/extension/src/browser/extension/inject/pageScript.ts index a88d4301..59658926 100644 --- a/extension/src/browser/extension/inject/pageScript.ts +++ b/extension/src/browser/extension/inject/pageScript.ts @@ -95,11 +95,6 @@ export interface ConfigWithExpandedMaxAge { readonly actionsDenylist?: string | readonly string[]; readonly actionsAllowlist?: string | readonly string[]; serialize?: boolean | SerializeWithImmutable; - readonly statesFilter?: (state: S, index?: number) => S; - readonly actionsFilter?: >( - action: A, - id?: number - ) => A; readonly stateSanitizer?: (state: S, index?: number) => S; readonly actionSanitizer?: >( action: A, @@ -202,14 +197,7 @@ function __REDUX_DEVTOOLS_EXTENSION__>( 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__>( 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 | undefined, diff --git a/extension/test/app/inject/enhancer.spec.js b/extension/test/app/inject/enhancer.spec.js index 9398fd5e..49229474 100644 --- a/extension/test/app/inject/enhancer.spec.js +++ b/extension/test/app/inject/enhancer.spec.js @@ -182,7 +182,6 @@ describe('Redux enhancer', () => { counter, window.__REDUX_DEVTOOLS_EXTENSION__({ actionsDenylist: ['SOME_ACTION'], - statesFilter: (state) => state, }) ); expect(typeof window.store).toBe('object'); diff --git a/packages/redux-devtools-utils/src/filters.ts b/packages/redux-devtools-utils/src/filters.ts index 14c8d3cb..b3557c30 100644 --- a/packages/redux-devtools-utils/src/filters.ts +++ b/packages/redux-devtools-utils/src/filters.ts @@ -20,23 +20,23 @@ export function arrToRegex(v: string | string[]) { function filterActions( actionsById: { [actionId: number]: PerformAction> }, - actionsFilter: ((action: Action, id: number) => Action) | undefined + actionSanitizer: ((action: Action, 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), })); }