Skip to content
Merged

v2.0.34 #4028

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions govtool/frontend/src/context/dataActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,32 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
isAdjusting.current = false;
}, []);

const gADetailsPathnameRegexp = /^.*\/governance_actions\/[a-fA-F0-9]{64}$/;
const userMovedToDifferentAppArea =
pathname !== lastPath &&
(!pathname.startsWith(lastPath) || lastPath === "" || lastPath === "/");
const userOpenedGADetails = gADetailsPathnameRegexp.test(pathname);
const userOpenedGADetailsFromCategoryPage =
lastPath.includes("governance_actions/category") &&
pathname.includes("governance_actions/");
userOpenedGADetails &&
lastPath.includes("governance_actions/category");
const userMovedFromGAListToCategoryPage =
lastPath.endsWith("governance_actions") &&
pathname.includes("governance_actions/category");
const userMovedFromGADetailsToListOrCategoryPage =
(gADetailsPathnameRegexp.test(lastPath) &&
pathname.includes("governance_actions")) ||
pathname.includes("governance_actions/category");

useEffect(() => {
isAdjusting.current = true;
if (userOpenedGADetails) {
return;
}

if (userMovedFromGADetailsToListOrCategoryPage && debouncedSearchText.length > 0) {
isAdjusting.current = false;
return;
}

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

useEffect(() => {
setLastPath(pathname);
}, [searchText, chosenFilters, chosenSorting]);
}, [pathname, searchText, chosenFilters, chosenSorting]);

const contextValue = useMemo(
() => ({
Expand Down
10 changes: 6 additions & 4 deletions govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const useGetProposalsQuery = ({
return allProposals.flatMap((proposal) => proposal.elements);
};

const { data, isLoading } = useQuery(
const { data, isLoading, isFetching } = useQuery(
[
QUERY_KEYS.useGetProposalsKey,
filters,
Expand All @@ -46,16 +46,18 @@ export const useGetProposalsQuery = ({
fetchProposals,
{
enabled,
refetchOnWindowFocus: true,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
keepPreviousData: true,
cacheTime: Infinity,
},
);

const isProposalsLoading = isLoading || isFetching;

const proposals = Object.values(groupByType(data) ?? []);

return {
isProposalsLoading: isLoading,
isProposalsLoading,
proposals,
};
};
Expand Down
Loading