Skip to content

Commit

Permalink
Improve speed of national table when no filters
Browse files Browse the repository at this point in the history
  • Loading branch information
clementprdhomme committed Oct 14, 2024
1 parent 4799735 commit f928612
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,14 @@ export const useData = (
[environment, filters, locationCode]
);

const isFiltering = useMemo(
() =>
Object.values(filters)
.filter(Boolean)
.some((value) => value.length > 0),
[filters]
);

const processData = useCallback(
(data: PaListResponse) => {
return [
Expand Down Expand Up @@ -707,7 +715,9 @@ export const useData = (
'pagination[pageSize]': pagination.pageSize,
'pagination[page]': pagination.pageIndex + 1,
sort: querySort,
'keep-if-children-match': true,
// This parameter makes sure Strapi retains the parent for which children match the filters
// but make the request slower, so it is only added when necessary
...(isFiltering ? { 'keep-if-children-match': true } : {}),
},
{
query: {
Expand Down

0 comments on commit f928612

Please sign in to comment.