From 2ddddbe50e1e74befcf1573b929754d2679cd035 Mon Sep 17 00:00:00 2001 From: Patricia Hillebrandt Date: Tue, 10 Jan 2023 15:17:51 +0100 Subject: [PATCH] useCollection hook: Do not bail early if isEditor (https://github.com/woocommerce/woocommerce-blocks/pull/8079) --- .../hooks/collections/use-collection-data.ts | 1 - .../context/hooks/collections/use-collection.ts | 14 +------------- .../assets/js/blocks/attribute-filter/block.tsx | 1 - 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/plugins/woocommerce-blocks/assets/js/base/context/hooks/collections/use-collection-data.ts b/plugins/woocommerce-blocks/assets/js/base/context/hooks/collections/use-collection-data.ts index a6d9ddc8ff2..74ff53eebcc 100644 --- a/plugins/woocommerce-blocks/assets/js/base/context/hooks/collections/use-collection-data.ts +++ b/plugins/woocommerce-blocks/assets/js/base/context/hooks/collections/use-collection-data.ts @@ -171,6 +171,5 @@ export const useCollectionData = ( { ...collectionDataQueryVars, }, shouldSelect: debouncedShouldSelect, - isEditor, } ); }; diff --git a/plugins/woocommerce-blocks/assets/js/base/context/hooks/collections/use-collection.ts b/plugins/woocommerce-blocks/assets/js/base/context/hooks/collections/use-collection.ts index 172fd11963f..656de8a6a31 100644 --- a/plugins/woocommerce-blocks/assets/js/base/context/hooks/collections/use-collection.ts +++ b/plugins/woocommerce-blocks/assets/js/base/context/hooks/collections/use-collection.ts @@ -5,7 +5,7 @@ import { COLLECTIONS_STORE_KEY as storeKey } from '@woocommerce/block-data'; import { useSelect } from '@wordpress/data'; import { useRef } from '@wordpress/element'; import { useShallowEqual, useThrowError } from '@woocommerce/base-hooks'; -import { isError, isObject } from '@woocommerce/types'; +import { isError } from '@woocommerce/types'; /** * This is a custom hook that is wired up to the `wc/store/collections` data @@ -61,7 +61,6 @@ export const useCollection = ( resourceValues = [], query = {}, shouldSelect = true, - isEditor = false, } = options; if ( ! namespace || ! resourceName ) { throw new Error( @@ -79,17 +78,6 @@ export const useCollection = ( const throwError = useThrowError(); const results = useSelect( ( select ) => { - if ( - isEditor && - isObject( currentResults?.current?.results ) && - Object.keys( currentResults.current.results ).length > 0 - ) { - return { - results: currentResults.current.results, - isLoading: false, - }; - } - if ( ! shouldSelect ) { return null; } diff --git a/plugins/woocommerce-blocks/assets/js/blocks/attribute-filter/block.tsx b/plugins/woocommerce-blocks/assets/js/blocks/attribute-filter/block.tsx index 2dcbd2db0d5..6c6ae94e74c 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/attribute-filter/block.tsx +++ b/plugins/woocommerce-blocks/assets/js/blocks/attribute-filter/block.tsx @@ -138,7 +138,6 @@ const AttributeFilterBlock = ( { resourceName: 'products/attributes/terms', resourceValues: [ attributeObject?.id || 0 ], shouldSelect: blockAttributes.attributeId > 0, - isEditor, } ); const filterAvailableTerms =