Reduce unread orders API response fields.

This commit is contained in:
Jeff Stieler 2019-07-17 09:56:13 -06:00
parent 9bbc4fa96d
commit 705379bdbb
2 changed files with 4 additions and 1 deletions

View File

@ -279,6 +279,7 @@ export default compose(
page: 1, page: 1,
per_page: QUERY_DEFAULTS.pageSize, per_page: QUERY_DEFAULTS.pageSize,
status: orderStatuses, status: orderStatuses,
_fields: [ 'id', 'date_created_gmt', 'status' ],
}; };
const actionableOrders = Array.from( getItems( 'orders', allOrdersQuery ).values() ); const actionableOrders = Array.from( getItems( 'orders', allOrdersQuery ).values() );

View File

@ -32,7 +32,7 @@ export function getUnreadNotes( select ) {
} }
export function getUnreadOrders( select ) { export function getUnreadOrders( select ) {
const { getItemsTotalCount, getItemsError, isGetItemsRequesting } = select( 'wc-api' ); const { getItems, getItemsTotalCount, getItemsError, isGetItemsRequesting } = select( 'wc-api' );
const orderStatuses = const orderStatuses =
wcSettings.wcAdminSettings.woocommerce_actionable_order_statuses || DEFAULT_ACTIONABLE_STATUSES; wcSettings.wcAdminSettings.woocommerce_actionable_order_statuses || DEFAULT_ACTIONABLE_STATUSES;
@ -44,8 +44,10 @@ export function getUnreadOrders( select ) {
page: 1, page: 1,
per_page: 1, // Core endpoint requires per_page > 0. per_page: 1, // Core endpoint requires per_page > 0.
status: orderStatuses, status: orderStatuses,
_fields: [ 'id' ],
}; };
getItems( 'orders', ordersQuery );
const totalOrders = getItemsTotalCount( 'orders', ordersQuery ); const totalOrders = getItemsTotalCount( 'orders', ordersQuery );
const isError = Boolean( getItemsError( 'orders', ordersQuery ) ); const isError = Boolean( getItemsError( 'orders', ordersQuery ) );
const isRequesting = isGetItemsRequesting( 'orders', ordersQuery ); const isRequesting = isGetItemsRequesting( 'orders', ordersQuery );