mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
✨ Create refresh actions for all stores
This commit is contained in:
parent
b2b0bb8d7a
commit
fe0f17a9ce
7 changed files with 86 additions and 2 deletions
|
@ -82,3 +82,16 @@ export function persist() {
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thunk action creator. Forces a data refresh from the REST API, replacing the current Redux values.
|
||||||
|
*
|
||||||
|
* @return {Function} The thunk function.
|
||||||
|
*/
|
||||||
|
export function refresh() {
|
||||||
|
return ( { dispatch, select } ) => {
|
||||||
|
dispatch.invalidateResolutionForStore();
|
||||||
|
|
||||||
|
select.persistentData();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,19 @@ export function persist() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thunk action creator. Forces a data refresh from the REST API, replacing the current Redux values.
|
||||||
|
*
|
||||||
|
* @return {Function} The thunk function.
|
||||||
|
*/
|
||||||
|
export function refresh() {
|
||||||
|
return ( { dispatch, select } ) => {
|
||||||
|
dispatch.invalidateResolutionForStore();
|
||||||
|
|
||||||
|
select.persistentData();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Side effect. Fetches the ISU-login URL for a sandbox account.
|
* Side effect. Fetches the ISU-login URL for a sandbox account.
|
||||||
*
|
*
|
||||||
|
|
|
@ -82,3 +82,16 @@ export function persist() {
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thunk action creator. Forces a data refresh from the REST API, replacing the current Redux values.
|
||||||
|
*
|
||||||
|
* @return {Function} The thunk function.
|
||||||
|
*/
|
||||||
|
export function refresh() {
|
||||||
|
return ( { dispatch, select } ) => {
|
||||||
|
dispatch.invalidateResolutionForStore();
|
||||||
|
|
||||||
|
select.persistentData();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ export function persist() {
|
||||||
*/
|
*/
|
||||||
export function refresh() {
|
export function refresh() {
|
||||||
return ( { dispatch, select } ) => {
|
return ( { dispatch, select } ) => {
|
||||||
dispatch.invalidateResolutionForStoreSelector( 'persistentData' );
|
dispatch.invalidateResolutionForStore();
|
||||||
|
|
||||||
select.persistentData();
|
select.persistentData();
|
||||||
};
|
};
|
||||||
|
|
|
@ -84,3 +84,16 @@ export function persist() {
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thunk action creator. Forces a data refresh from the REST API, replacing the current Redux values.
|
||||||
|
*
|
||||||
|
* @return {Function} The thunk function.
|
||||||
|
*/
|
||||||
|
export function refresh() {
|
||||||
|
return ( { dispatch, select } ) => {
|
||||||
|
dispatch.invalidateResolutionForStore();
|
||||||
|
|
||||||
|
select.persistentData();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -82,3 +82,16 @@ export function persist() {
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thunk action creator. Forces a data refresh from the REST API, replacing the current Redux values.
|
||||||
|
*
|
||||||
|
* @return {Function} The thunk function.
|
||||||
|
*/
|
||||||
|
export function refresh() {
|
||||||
|
return ( { dispatch, select } ) => {
|
||||||
|
dispatch.invalidateResolutionForStore();
|
||||||
|
|
||||||
|
select.persistentData();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ export const setCompletedTodos = ( completedTodos ) => ( {
|
||||||
|
|
||||||
// Thunks
|
// Thunks
|
||||||
|
|
||||||
|
// TODO: Possibly, this should be a resolver?
|
||||||
export function fetchTodos() {
|
export function fetchTodos() {
|
||||||
return async () => {
|
return async () => {
|
||||||
const response = await apiFetch( { path: REST_PATH } );
|
const response = await apiFetch( { path: REST_PATH } );
|
||||||
|
@ -46,9 +47,14 @@ export function fetchTodos() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thunk action creator. Triggers the persistence of store data to the server.
|
||||||
|
*
|
||||||
|
* @return {Function} The thunk function.
|
||||||
|
*/
|
||||||
export function persist() {
|
export function persist() {
|
||||||
return async ( { select } ) => {
|
return async ( { select } ) => {
|
||||||
return await apiFetch( {
|
await apiFetch( {
|
||||||
path: REST_PERSIST_PATH,
|
path: REST_PERSIST_PATH,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: select.persistentData(),
|
data: select.persistentData(),
|
||||||
|
@ -56,6 +62,19 @@ export function persist() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thunk action creator. Forces a data refresh from the REST API, replacing the current Redux values.
|
||||||
|
*
|
||||||
|
* @return {Function} The thunk function.
|
||||||
|
*/
|
||||||
|
export function refresh() {
|
||||||
|
return ( { dispatch, select } ) => {
|
||||||
|
dispatch.invalidateResolutionForStore();
|
||||||
|
|
||||||
|
select.persistentData();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function resetDismissedTodos() {
|
export function resetDismissedTodos() {
|
||||||
return async ( { dispatch } ) => {
|
return async ( { dispatch } ) => {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue