Merge pull request woocommerce/woocommerce-admin#980 from woocommerce/fix/911-first-request-is-requesting

Order data: fix `isGetOrdersRequesting()` for the first request.
This commit is contained in:
Jeff Stieler 2018-12-03 14:58:53 -07:00 committed by GitHub
commit 0c76f550a5
1 changed files with 16 additions and 1 deletions

View File

@ -1,4 +1,10 @@
/** @format */
/**
* External dependencies
*/
import { isNil } from 'lodash';
/**
* Internal dependencies
*/
@ -26,7 +32,16 @@ const getOrdersTotalCount = ( getResource, requireResource ) => (
const isGetOrdersRequesting = getResource => ( query = {} ) => {
const resourceName = getResourceName( 'order-query', query );
const { lastRequested, lastReceived } = getResource( resourceName );
return lastRequested && lastRequested > lastReceived;
if ( isNil( lastRequested ) ) {
return false;
}
if ( isNil( lastReceived ) ) {
return true;
}
return lastRequested > lastReceived;
};
const isGetOrdersError = getResource => ( query = {} ) => {