Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Stop reading Product IDs from asset store in filter blocks #10195

Merged
merged 4 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { useState, useEffect, useMemo } from '@wordpress/element';
import { useDebounce } from 'use-debounce';
import { isEmpty, objectHasProp } from '@woocommerce/types';
import { objectHasProp } from '@woocommerce/types';
import { sort } from 'fast-sort';
import { useShallowEqual } from '@woocommerce/base-hooks';

Expand Down Expand Up @@ -46,7 +46,6 @@ interface UseCollectionDataProps {
queryStock?: boolean;
queryRating?: boolean;
queryState: Record< string, unknown >;
productIds?: number[];
isEditor?: boolean;
}

Expand All @@ -56,7 +55,6 @@ export const useCollectionData = ( {
queryStock,
queryRating,
queryState,
productIds,
isEditor = false,
}: UseCollectionDataProps ) => {
let context = useQueryStateContext();
Expand Down Expand Up @@ -166,7 +164,6 @@ export const useCollectionData = ( {
per_page: undefined,
orderby: undefined,
order: undefined,
...( ! isEmpty( productIds ) && { include: productIds } ),
...collectionDataQueryVars,
},
shouldSelect: debouncedShouldSelect,
Expand Down
5 changes: 0 additions & 5 deletions assets/js/blocks/attribute-filter/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ const AttributeFilterBlock = ( {
isString
);

const productIds = isEditor
? []
: getSettingWithCoercion( 'product_ids', [], Array.isArray );

const [ hasSetFilterDefaultsFromUrl, setHasSetFilterDefaultsFromUrl ] =
useState( false );

Expand Down Expand Up @@ -144,7 +140,6 @@ const AttributeFilterBlock = ( {
queryState: {
...queryState,
},
productIds,
isEditor,
} );

Expand Down
5 changes: 0 additions & 5 deletions assets/js/blocks/price-filter/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ const PriceFilterBlock = ( {
isBoolean
);

const productIds = isEditor
? []
: getSettingWithCoercion( 'product_ids', [], Array.isArray );

const [ hasSetFilterDefaultsFromUrl, setHasSetFilterDefaultsFromUrl ] =
useState( false );

Expand All @@ -112,7 +108,6 @@ const PriceFilterBlock = ( {
const { results, isLoading } = useCollectionData( {
queryPrices: true,
queryState,
productIds,
isEditor,
} );

Expand Down
5 changes: 0 additions & 5 deletions assets/js/blocks/stock-filter/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ const StockStatusFilterBlock = ( {
{}
);

const productIds = isEditor
? []
: getSettingWithCoercion( 'product_ids', [], Array.isArray );

const STOCK_STATUS_OPTIONS: { current: Current } = useRef(
getSetting( 'hideOutOfStockItems', false )
? otherStockStatusOptions
Expand Down Expand Up @@ -111,7 +107,6 @@ const StockStatusFilterBlock = ( {
useCollectionData( {
queryStock: true,
queryState,
productIds,
isEditor,
} );

Expand Down