mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
✨ Replace isBusy with new activity-state manager
This commit is contained in:
parent
405c397331
commit
9786a18eb0
5 changed files with 77 additions and 16 deletions
|
@ -14,7 +14,7 @@ import ACTION_TYPES from './action-types';
|
|||
|
||||
const defaultTransient = {
|
||||
isReady: false,
|
||||
isBusy: false,
|
||||
activities: new Map(),
|
||||
|
||||
// Read only values, provided by the server via hydrate.
|
||||
wooSettings: {
|
||||
|
@ -57,6 +57,21 @@ const commonReducer = createReducer( defaultTransient, defaultPersistent, {
|
|||
return cleanState;
|
||||
},
|
||||
|
||||
[ ACTION_TYPES.START_ACTIVITY ]: ( state, payload ) => {
|
||||
return setTransient( state, {
|
||||
activities: new Map( state.activities ).set(
|
||||
payload.id,
|
||||
payload.description
|
||||
),
|
||||
} );
|
||||
},
|
||||
|
||||
[ ACTION_TYPES.STOP_ACTIVITY ]: ( state, payload ) => {
|
||||
const newActivities = new Map( state.activities );
|
||||
newActivities.delete( payload.id );
|
||||
return setTransient( state, { activities: newActivities } );
|
||||
},
|
||||
|
||||
[ ACTION_TYPES.HYDRATE ]: ( state, payload ) => {
|
||||
const newState = setPersistent( state, payload.data );
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue