Skip to content

Commit 50ff9dc

Browse files
authored
Merge pull request #4027 from IntersectMBO/develop
v2.0.34
2 parents 47dfbca + aa83ac2 commit 50ff9dc

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

govtool/frontend/src/context/dataActionsBar.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,32 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
6868
isAdjusting.current = false;
6969
}, []);
7070

71+
const gADetailsPathnameRegexp = /^.*\/governance_actions\/[a-fA-F0-9]{64}$/;
7172
const userMovedToDifferentAppArea =
7273
pathname !== lastPath &&
7374
(!pathname.startsWith(lastPath) || lastPath === "" || lastPath === "/");
75+
const userOpenedGADetails = gADetailsPathnameRegexp.test(pathname);
7476
const userOpenedGADetailsFromCategoryPage =
75-
lastPath.includes("governance_actions/category") &&
76-
pathname.includes("governance_actions/");
77+
userOpenedGADetails &&
78+
lastPath.includes("governance_actions/category");
7779
const userMovedFromGAListToCategoryPage =
7880
lastPath.endsWith("governance_actions") &&
7981
pathname.includes("governance_actions/category");
82+
const userMovedFromGADetailsToListOrCategoryPage =
83+
(gADetailsPathnameRegexp.test(lastPath) &&
84+
pathname.includes("governance_actions")) ||
85+
pathname.includes("governance_actions/category");
8086

8187
useEffect(() => {
8288
isAdjusting.current = true;
89+
if (userOpenedGADetails) {
90+
return;
91+
}
92+
93+
if (userMovedFromGADetailsToListOrCategoryPage && debouncedSearchText.length > 0) {
94+
isAdjusting.current = false;
95+
return;
96+
}
8397

8498
if (
8599
(!pathname.includes("drep_directory") &&
@@ -93,7 +107,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
93107

94108
useEffect(() => {
95109
setLastPath(pathname);
96-
}, [searchText, chosenFilters, chosenSorting]);
110+
}, [pathname, searchText, chosenFilters, chosenSorting]);
97111

98112
const contextValue = useMemo(
99113
() => ({

govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const useGetProposalsQuery = ({
3333
return allProposals.flatMap((proposal) => proposal.elements);
3434
};
3535

36-
const { data, isLoading } = useQuery(
36+
const { data, isLoading, isFetching } = useQuery(
3737
[
3838
QUERY_KEYS.useGetProposalsKey,
3939
filters,
@@ -46,16 +46,18 @@ export const useGetProposalsQuery = ({
4646
fetchProposals,
4747
{
4848
enabled,
49-
refetchOnWindowFocus: true,
49+
refetchOnWindowFocus: false,
50+
refetchOnReconnect: false,
5051
keepPreviousData: true,
51-
cacheTime: Infinity,
5252
},
5353
);
5454

55+
const isProposalsLoading = isLoading || isFetching;
56+
5557
const proposals = Object.values(groupByType(data) ?? []);
5658

5759
return {
58-
isProposalsLoading: isLoading,
60+
isProposalsLoading,
5961
proposals,
6062
};
6163
};

0 commit comments

Comments
 (0)