mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
♻️ Rename reducer methods for better clarity
This commit is contained in:
parent
4b90f84536
commit
4de4e05829
7 changed files with 49 additions and 49 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue