mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 19:54:15 +08:00
♻️ Adjust “webhooks” property in Redux state
This commit is contained in:
parent
6591889079
commit
67a6d9e765
4 changed files with 26 additions and 14 deletions
|
@ -45,12 +45,13 @@ const defaultTransient = Object.freeze( {
|
|||
enabled: false,
|
||||
},
|
||||
} ),
|
||||
|
||||
webhooks: Object.freeze( [] ),
|
||||
} );
|
||||
|
||||
const defaultPersistent = Object.freeze( {
|
||||
useSandbox: false,
|
||||
useManualConnection: false,
|
||||
webhooks: [],
|
||||
} );
|
||||
|
||||
// Reducer logic.
|
||||
|
@ -105,16 +106,18 @@ const commonReducer = createReducer( defaultTransient, defaultPersistent, {
|
|||
const newState = setPersistent( state, payload.data );
|
||||
|
||||
// Populate read-only properties.
|
||||
[ 'wooSettings', 'merchant', 'features' ].forEach( ( key ) => {
|
||||
if ( ! payload[ key ] ) {
|
||||
return;
|
||||
}
|
||||
[ 'wooSettings', 'merchant', 'features', 'webhooks' ].forEach(
|
||||
( key ) => {
|
||||
if ( ! payload[ key ] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
newState[ key ] = Object.freeze( {
|
||||
...newState[ key ],
|
||||
...payload[ key ],
|
||||
} );
|
||||
} );
|
||||
newState[ key ] = Object.freeze( {
|
||||
...newState[ key ],
|
||||
...payload[ key ],
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
return newState;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue