mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
♻️ Common store: Detach a reducer from controls
This commit is contained in:
parent
d90a893a38
commit
4f5b254452
4 changed files with 11 additions and 1 deletions
|
@ -12,6 +12,7 @@ export default {
|
|||
SET_PERSISTENT: 'ppcp/common/SET_PERSISTENT',
|
||||
RESET: 'ppcp/common/RESET',
|
||||
HYDRATE: 'ppcp/common/HYDRATE',
|
||||
RESET_MERCHANT: 'ppcp/common/RESET_MERCHANT',
|
||||
|
||||
// Activity management (advanced solution that replaces the isBusy state).
|
||||
START_ACTIVITY: 'ppcp/common/START_ACTIVITY',
|
||||
|
|
|
@ -173,6 +173,7 @@ export function disconnectMerchant() {
|
|||
export function refreshMerchantData() {
|
||||
return async ( { dispatch } ) => {
|
||||
try {
|
||||
await dispatch.resetMerchant();
|
||||
const result = await apiFetch( {
|
||||
path: REST_HYDRATE_MERCHANT_PATH,
|
||||
} );
|
||||
|
|
|
@ -110,6 +110,13 @@ export const setManualConnectionMode = ( useManualConnection ) =>
|
|||
export const setWebhooks = ( webhooks ) =>
|
||||
setPersistent( 'webhooks', webhooks );
|
||||
|
||||
/**
|
||||
* Reset merchant details in the store.
|
||||
*
|
||||
* @return {Action} The action.
|
||||
*/
|
||||
export const resetMerchant = () => ( { type: ACTION_TYPES.RESET_MERCHANT } );
|
||||
|
||||
// Activity control - see useBusyState() hook.
|
||||
|
||||
/**
|
||||
|
|
|
@ -106,7 +106,8 @@ const commonReducer = createReducer( defaultTransient, defaultPersistent, {
|
|||
return changeTransient( state, { activities: newActivities } );
|
||||
},
|
||||
|
||||
[ ACTION_TYPES.DO_REFRESH_MERCHANT ]: ( state ) => ( {
|
||||
// Instantly reset the merchant data and features before refreshing the details.
|
||||
[ ACTION_TYPES.RESET_MERCHANT ]: ( state ) => ( {
|
||||
...state,
|
||||
merchant: Object.freeze( { ...defaultTransient.merchant } ),
|
||||
features: Object.freeze( { ...defaultTransient.features } ),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue