Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Core Data: Remove unused reducers
  • Loading branch information
Mamaduka committed Aug 22, 2025
commit 2576f65e6fd2966a54550db0f5ba60d91ee1d6a6
42 changes: 0 additions & 42 deletions packages/core-data/src/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,6 @@ import { rootEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';

/** @typedef {import('./types').AnyFunction} AnyFunction */

/**
* Reducer managing terms state. Keyed by taxonomy slug, the value is either
* undefined (if no request has been made for given taxonomy), null (if a
* request is in-flight for given taxonomy), or the array of terms for the
* taxonomy.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
*/
export function terms( state = {}, action ) {
switch ( action.type ) {
case 'RECEIVE_TERMS':
return {
...state,
[ action.taxonomy ]: action.terms,
};
}

return state;
}

/**
* Reducer managing authors state. Keyed by id.
*
Expand Down Expand Up @@ -92,23 +69,6 @@ export function currentUser( state = {}, action ) {
return state;
}

/**
* Reducer managing taxonomies.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
*/
export function taxonomies( state = [], action ) {
switch ( action.type ) {
case 'RECEIVE_TAXONOMIES':
return action.taxonomies;
}

return state;
}

/**
* Reducer managing the current theme.
*
Expand Down Expand Up @@ -648,15 +608,13 @@ export function registeredPostMeta( state = {}, action ) {
}

export default combineReducers( {
terms,
users,
currentTheme,
currentGlobalStylesId,
currentUser,
themeGlobalStyleVariations,
themeBaseGlobalStyles,
themeGlobalStyleRevisions,
taxonomies,
entities,
editsReference,
undoManager,
Expand Down
22 changes: 0 additions & 22 deletions packages/core-data/src/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,13 @@ import deepFreeze from 'deep-freeze';
* Internal dependencies
*/
import {
terms,
entities,
embedPreviews,
userPermissions,
autosaves,
currentUser,
} from '../reducer';

describe( 'terms()', () => {
it( 'returns an empty object by default', () => {
const state = terms( undefined, {} );

expect( state ).toEqual( {} );
} );

it( 'returns with received terms', () => {
const originalState = deepFreeze( {} );
const state = terms( originalState, {
type: 'RECEIVE_TERMS',
taxonomy: 'categories',
terms: [ { id: 1 } ],
} );

expect( state ).toEqual( {
categories: [ { id: 1 } ],
} );
} );
} );

describe( 'entities', () => {
// See also unit tests at `queried-data/test/reducer.js`, which are more
// thorough in testing the behavior of what is tracked here as the
Expand Down
Loading