Updating unread stock indicator on stock update (https://github.com/woocommerce/woocommerce-admin/pull/3550)
* Force refetch of low product query after updating stock * Continue showing unread indicator while fetching
This commit is contained in:
parent
7164e021fc
commit
d5444f6351
|
@ -88,7 +88,7 @@ export function getUnapprovedReviews( select ) {
|
|||
}
|
||||
|
||||
export function getUnreadStock( select ) {
|
||||
const { getItems, getItemsError, getItemsTotalCount, isGetItemsRequesting } = select( 'wc-api' );
|
||||
const { getItems, getItemsError, getItemsTotalCount } = select( 'wc-api' );
|
||||
const productsQuery = {
|
||||
page: 1,
|
||||
per_page: 1,
|
||||
|
@ -98,9 +98,8 @@ export function getUnreadStock( select ) {
|
|||
getItems( 'products', productsQuery );
|
||||
const lowInStockCount = getItemsTotalCount( 'products', productsQuery );
|
||||
const isError = Boolean( getItemsError( 'products', productsQuery ) );
|
||||
const isRequesting = isGetItemsRequesting( 'products', productsQuery );
|
||||
|
||||
if ( isError || isRequesting ) {
|
||||
if ( isError ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,8 +117,19 @@ function updateLocally( resourceNames, data ) {
|
|||
return updateableTypes.includes( getResourcePrefix( name ) );
|
||||
} );
|
||||
|
||||
const lowStockResourceName = getResourceName( 'items-query-products', {
|
||||
page: 1,
|
||||
per_page: 1,
|
||||
low_in_stock: true,
|
||||
status: 'publish',
|
||||
} );
|
||||
|
||||
return filteredNames.map( async resourceName => {
|
||||
return { [ resourceName ]: { data: data[ resourceName ] } };
|
||||
return {
|
||||
[ resourceName ]: { data: data[ resourceName ] },
|
||||
// Force low stock products to be re-fetched after updating an item.
|
||||
[ lowStockResourceName ]: { lastReceived: null },
|
||||
};
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue