Skip to content

Commit 8e2d9ea

Browse files
authored
Merge pull request #2619 from IntersectMBO/fix/passing-random-sorting-to-gov-actions-on-disconnected-wallet
fix: passing random sorting to governance actions request
2 parents a06cbf4 + b916ee6 commit 8e2d9ea

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ changes.
1818

1919
- Fix counting submitted votes [Issue 2609](https://github.com/IntersectMBO/govtool/issues/2609)
2020
- Fix opening relative paths in external links
21+
- Fix passing random sorting to governance actions on disconnected wallet
2122

2223
### Changed
2324

govtool/frontend/src/context/dataActionsBar.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import React, {
88
useEffect,
99
useMemo,
1010
FC,
11+
useRef,
1112
} from "react";
1213
import { useLocation } from "react-router-dom";
1314

@@ -41,7 +42,7 @@ interface ProviderProps {
4142
}
4243

4344
const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
44-
const [isAdjusting, setIsAdjusting] = useState<boolean>(true);
45+
const isAdjusting = useRef<boolean>(false);
4546
const [searchText, setSearchText] = useState<string>("");
4647
const debouncedSearchText = useDebounce(searchText, 300);
4748
const [filtersOpen, setFiltersOpen] = useState<boolean>(false);
@@ -64,11 +65,12 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
6465
setSearchText("");
6566
setChosenFilters([]);
6667
setChosenSorting("");
67-
setIsAdjusting(false);
68+
isAdjusting.current = false;
6869
}, []);
6970

7071
const userMovedToDifferentAppArea =
71-
pathname !== lastPath && !pathname.startsWith(lastPath);
72+
pathname !== lastPath &&
73+
(!pathname.startsWith(lastPath) || lastPath === "");
7274
const userOpenedGADetailsFromCategoryPage =
7375
lastPath.includes("governance_actions/category") &&
7476
pathname.includes("governance_actions/");
@@ -77,7 +79,8 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
7779
pathname.includes("governance_actions/category");
7880

7981
useEffect(() => {
80-
setIsAdjusting(true);
82+
isAdjusting.current = true;
83+
8184
if (
8285
(!pathname.includes("drep_directory") &&
8386
userMovedToDifferentAppArea &&
@@ -94,7 +97,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
9497

9598
const contextValue = useMemo(
9699
() => ({
97-
isAdjusting,
100+
isAdjusting: isAdjusting.current,
98101
chosenFilters,
99102
chosenFiltersLength: chosenFilters.length,
100103
chosenSorting,
@@ -111,7 +114,6 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
111114
sortOpen,
112115
}),
113116
[
114-
isAdjusting,
115117
chosenFilters,
116118
chosenSorting,
117119
debouncedSearchText,
@@ -120,6 +122,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
120122
sortOpen,
121123
closeFilters,
122124
closeSorts,
125+
pathname,
123126
],
124127
);
125128

govtool/frontend/src/pages/GovernanceActions.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const defaultCategories = GOVERNANCE_ACTIONS_FILTERS.map(
2323
);
2424

2525
export const GovernanceActions = () => {
26-
const { debouncedSearchText, ...dataActionsBarProps } = useDataActionsBar();
26+
const { debouncedSearchText, isAdjusting, ...dataActionsBarProps } =
27+
useDataActionsBar();
2728
const { chosenFilters, chosenSorting } = dataActionsBarProps;
2829
const { isMobile, pagePadding } = useScreenDimension();
2930
const { isEnabled } = useCardano();
@@ -37,6 +38,7 @@ export const GovernanceActions = () => {
3738
filters: queryFilters,
3839
sorting: chosenSorting,
3940
searchPhrase: debouncedSearchText,
41+
enabled: !isAdjusting,
4042
});
4143

4244
useEffect(() => {

0 commit comments

Comments
 (0)