Merge pull request woocommerce/woocommerce-admin#2387 from woocommerce/fix/2365-improve-tab-switching-read-suppression
Improve hidden tab suppression/fix rapid requests
This commit is contained in:
commit
ed21ccf62e
|
@ -36,6 +36,11 @@ function createWcApiSpec() {
|
|||
},
|
||||
operations: {
|
||||
read( resourceNames ) {
|
||||
if ( document.hidden ) {
|
||||
// Don't do any read updates while the tab isn't active.
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
...imports.operations.read( resourceNames ),
|
||||
...items.operations.read( resourceNames ),
|
||||
|
|
|
@ -19,11 +19,12 @@ function createStore( name ) {
|
|||
function createDataHandlers( store ) {
|
||||
return {
|
||||
dataRequested: resourceNames => {
|
||||
const { resources } = store.getState();
|
||||
const newResources = resourceNames.some( resourceName => ! resources[ resourceName ] );
|
||||
if ( ! newResources && document.hidden ) {
|
||||
// This is a temporary fix until it can be resolved upstream in fresh-data.
|
||||
// See: https://github.com/woocommerce/woocommerce-admin/pull/2387/files#r292355276
|
||||
if ( document.hidden ) {
|
||||
return;
|
||||
}
|
||||
|
||||
store.dispatch( {
|
||||
type: 'FRESH_DATA_REQUESTED',
|
||||
resourceNames,
|
||||
|
|
Loading…
Reference in New Issue