Skip to content

Commit 3146682

Browse files
committed
Fix duplicate requests on filtering
Removed duplicate fetch behavior in search/filter apply logic by avoiding page-navigation fetch plus manual reload in the same interaction.
1 parent a187168 commit 3146682

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/components/shared/TableFilters.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import {
1313
resetFilterValues,
1414
} from "../../slices/tableFilterSlice";
1515
import {
16-
goToPage,
17-
} from "../../thunks/tableThunks";
16+
deselectAll,
17+
setOffset,
18+
setPageActive,
19+
} from "../../slices/tableSlice";
1820
import TableFilterProfiles from "./TableFilterProfiles";
1921
import { availableHotkeys } from "../../configs/hotkeysConfig";
2022
import { useHotkeys } from "react-hotkeys-hook";
@@ -136,7 +138,9 @@ const TableFilters = ({
136138
// This helps increase performance by reducing the number of calls to load resources.
137139
const applyFilterChangesDebounced = async () => {
138140
// No matter what, we go to page one.
139-
dispatch(goToPage(0));
141+
dispatch(deselectAll());
142+
dispatch(setOffset(0));
143+
dispatch(setPageActive(1));
140144
// Reload of resource
141145
await loadResource();
142146
};
@@ -201,7 +205,9 @@ const TableFilters = ({
201205
setFilterSelector(false);
202206
setSelectedFilter("");
203207
// Reload of resource after going to very first page.
204-
dispatch(goToPage(0));
208+
dispatch(deselectAll());
209+
dispatch(setOffset(0));
210+
dispatch(setPageActive(1));
205211
await loadResource();
206212
}
207213
}

0 commit comments

Comments
 (0)