mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 12:25:15 +08:00
🔥 Remove isSaving; move isBusy to common store
This commit is contained in:
parent
10a3767e2f
commit
2b2b24e434
7 changed files with 15 additions and 43 deletions
|
@ -36,28 +36,6 @@ export const setIsReady = ( isReady ) => ( {
|
|||
payload: { isReady },
|
||||
} );
|
||||
|
||||
/**
|
||||
* Transient. Changes the "saving" flag.
|
||||
*
|
||||
* @param {boolean} isSaving
|
||||
* @return {Action} The action.
|
||||
*/
|
||||
export const setIsSaving = ( isSaving ) => ( {
|
||||
type: ACTION_TYPES.SET_TRANSIENT,
|
||||
payload: { isSaving },
|
||||
} );
|
||||
|
||||
/**
|
||||
* Transient. Changes the "manual connection is busy" flag.
|
||||
*
|
||||
* @param {boolean} isBusy
|
||||
* @return {Action} The action.
|
||||
*/
|
||||
export const setIsBusy = ( isBusy ) => ( {
|
||||
type: ACTION_TYPES.SET_TRANSIENT,
|
||||
payload: { isBusy },
|
||||
} );
|
||||
|
||||
/**
|
||||
* Persistent. Set the full onboarding details, usually during app initialization.
|
||||
*
|
||||
|
@ -165,9 +143,7 @@ export const setProducts = ( products ) => ( {
|
|||
export const persist = function* () {
|
||||
const data = yield select( STORE_NAME ).persistentData();
|
||||
|
||||
yield setIsSaving( true );
|
||||
yield { type: ACTION_TYPES.DO_PERSIST_DATA, data };
|
||||
yield setIsSaving( false );
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -179,15 +155,12 @@ export const connectViaIdAndSecret = function* () {
|
|||
const { clientId, clientSecret, useSandbox } =
|
||||
yield select( STORE_NAME ).persistentData();
|
||||
|
||||
yield setIsBusy( true );
|
||||
|
||||
const result = yield {
|
||||
type: ACTION_TYPES.DO_MANUAL_CONNECTION,
|
||||
clientId,
|
||||
clientSecret,
|
||||
useSandbox,
|
||||
};
|
||||
yield setIsBusy( false );
|
||||
|
||||
return result;
|
||||
};
|
||||
|
|
|
@ -41,9 +41,7 @@ const useOnboardingDetails = () => {
|
|||
const flags = useSelect( ( select ) => select( STORE_NAME ).flags(), [] );
|
||||
|
||||
// Transient accessors.
|
||||
const isSaving = useTransient( 'isSaving' );
|
||||
const isReady = useTransient( 'isReady' );
|
||||
const isBusy = useTransient( 'isBusy' );
|
||||
|
||||
// Persistent accessors.
|
||||
const step = usePersistent( 'step' );
|
||||
|
@ -68,9 +66,8 @@ const useOnboardingDetails = () => {
|
|||
};
|
||||
|
||||
return {
|
||||
isSaving,
|
||||
flags,
|
||||
isReady,
|
||||
isBusy,
|
||||
step,
|
||||
setStep: ( value ) => setDetailAndPersist( setStep, value ),
|
||||
completed,
|
||||
|
@ -91,14 +88,11 @@ const useOnboardingDetails = () => {
|
|||
setDetailAndPersist( setIsCasualSeller, value ),
|
||||
products,
|
||||
toggleProduct,
|
||||
flags,
|
||||
};
|
||||
};
|
||||
|
||||
export const useConnection = () => {
|
||||
const {
|
||||
isSaving,
|
||||
isBusy,
|
||||
isSandboxMode,
|
||||
setSandboxMode,
|
||||
isManualConnectionMode,
|
||||
|
@ -110,8 +104,6 @@ export const useConnection = () => {
|
|||
} = useOnboardingDetails();
|
||||
|
||||
return {
|
||||
isSaving,
|
||||
isBusy,
|
||||
isSandboxMode,
|
||||
setSandboxMode,
|
||||
isManualConnectionMode,
|
||||
|
|
|
@ -14,8 +14,6 @@ import ACTION_TYPES from './action-types';
|
|||
|
||||
const defaultTransient = {
|
||||
isReady: false,
|
||||
isSaving: false,
|
||||
isBusy: false,
|
||||
|
||||
// Read only values, provided by the server.
|
||||
flags: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue