Skip to content

Commit

Permalink
Debounce filtered planning unit _count_ updates
Browse files Browse the repository at this point in the history
  • Loading branch information
underbluewaters committed Nov 17, 2024
1 parent 765bb92 commit e444935
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/client/src/formElements/FilterInputContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { FilterLayerManager } from "./FilterLayerManager";
import { MapContext } from "../dataLayers/MapContextManager";
import { FormElementDetailsFragment } from "../generated/graphql";
import useDebounce from "../useDebounce";

export type FilterGeostatsAttribute = Pick<
GeostatsAttribute,
Expand Down Expand Up @@ -153,12 +154,14 @@ export function FilterInputServiceContextProvider({
};
}, [state, getAttributeDetails]);

const debouncedStartingProperties = useDebounce(startingProperties, 100);

useEffect(() => {
if (startingProperties && state.metadata) {
if (debouncedStartingProperties && state.metadata) {
if (filterLayerManager) {
const filterString = filterStateToSearchString(
filterDefaults(
initialFilterState(startingProperties, formElements),
initialFilterState(debouncedStartingProperties, formElements),
state.metadata
)
);
Expand All @@ -173,7 +176,6 @@ export function FilterInputServiceContextProvider({
filterString: "",
}));
} else if (serviceLocation) {
// TODO: update count from service
setState((prev) => ({
...prev,
updatingCount: true,
Expand Down Expand Up @@ -201,7 +203,7 @@ export function FilterInputServiceContextProvider({
}
}
}, [
startingProperties,
debouncedStartingProperties,
state.metadata,
filterLayerManager,
formElements,
Expand Down

0 comments on commit e444935

Please sign in to comment.