♻️ Rename reducer methods for better clarity

This commit is contained in:
Philipp Stracker 2025-01-21 15:33:03 +01:00
parent 4b90f84536
commit 4de4e05829
No known key found for this signature in database
7 changed files with 49 additions and 49 deletions

View file

@ -7,7 +7,7 @@
* @file
*/
import { createReducer, createSetters } from '../utils';
import { createReducer, createReducerSetters } from '../utils';
import ACTION_TYPES from './action-types';
// Store structure.
@ -57,21 +57,21 @@ const defaultPersistent = Object.freeze( {
// Reducer logic.
const [ setTransient, setPersistent ] = createSetters(
const [ changeTransient, changePersistent ] = createReducerSetters(
defaultTransient,
defaultPersistent
);
const commonReducer = createReducer( defaultTransient, defaultPersistent, {
[ ACTION_TYPES.SET_TRANSIENT ]: ( state, action ) =>
setTransient( state, action ),
changeTransient( state, action ),
[ ACTION_TYPES.SET_PERSISTENT ]: ( state, action ) =>
setPersistent( state, action ),
changePersistent( state, action ),
[ ACTION_TYPES.RESET ]: ( state ) => {
const cleanState = setTransient(
setPersistent( state, defaultPersistent ),
const cleanState = changeTransient(
changePersistent( state, defaultPersistent ),
defaultTransient
);
@ -85,7 +85,7 @@ const commonReducer = createReducer( defaultTransient, defaultPersistent, {
},
[ ACTION_TYPES.START_ACTIVITY ]: ( state, payload ) => {
return setTransient( state, {
return changeTransient( state, {
activities: new Map( state.activities ).set(
payload.id,
payload.description
@ -96,7 +96,7 @@ const commonReducer = createReducer( defaultTransient, defaultPersistent, {
[ ACTION_TYPES.STOP_ACTIVITY ]: ( state, payload ) => {
const newActivities = new Map( state.activities );
newActivities.delete( payload.id );
return setTransient( state, { activities: newActivities } );
return changeTransient( state, { activities: newActivities } );
},
[ ACTION_TYPES.DO_REFRESH_MERCHANT ]: ( state ) => ( {
@ -106,7 +106,7 @@ const commonReducer = createReducer( defaultTransient, defaultPersistent, {
} ),
[ ACTION_TYPES.HYDRATE ]: ( state, payload ) => {
const newState = setPersistent( state, payload.data );
const newState = changePersistent( state, payload.data );
// Populate read-only properties.
[ 'wooSettings', 'merchant', 'features', 'webhooks' ].forEach(