Skip to content

Commit b10469f

Browse files
committed
fix(#2994): fix refetching the drep directory
1 parent 285a821 commit b10469f

File tree

7 files changed

+246
-66
lines changed

7 files changed

+246
-66
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ changes.
2424
- Fix crashing backend on unhandled missing proposal from vote [Issue 2920](https://github.com/IntersectMBO/govtool/issues/2920)
2525
- Remove abstain votes (not auto abstain) from total DRep stake
2626
- Fix counting committee members [Issue 2948](https://github.com/IntersectMBO/govtool/issues/2948)
27+
- Fix refetching DRep list on every enter [Issue 2994](https://github.com/IntersectMBO/govtool/issues/2994)
2728

2829
### Changed
2930

govtool/frontend/src/components/molecules/DataActionsBar.tsx

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -57,64 +57,62 @@ export const DataActionsBar: FC<DataActionsBarProps> = ({ ...props }) => {
5757
} = theme;
5858

5959
return (
60-
<>
61-
<Box alignItems="center" display="flex" justifyContent="space-between">
62-
<InputBase
63-
inputProps={{ "data-testid": "search-input" }}
64-
onChange={(e) => setSearchText(e.target.value)}
65-
placeholder="Search..."
66-
value={searchText}
67-
startAdornment={
68-
<Search
69-
style={{
70-
color: "#99ADDE",
71-
height: 16,
72-
marginRight: 4,
73-
width: 16,
74-
}}
75-
/>
76-
}
77-
sx={{
78-
bgcolor: "white",
79-
border: 1,
80-
borderColor: "secondaryBlue",
81-
borderRadius: 50,
82-
boxShadow: `2px 2px 20px 0px ${boxShadow2}`,
83-
fontSize: 11,
84-
fontWeight: 500,
85-
height: 48,
86-
padding: "16px 24px",
87-
maxWidth: 500,
88-
}}
89-
/>
90-
<OrderActionsChip
91-
chosenFiltersLength={chosenFiltersLength}
92-
filtersOpen={filtersOpen}
93-
isFiltering={isFiltering}
94-
setFiltersOpen={setFiltersOpen}
95-
chosenSorting={chosenSorting}
96-
setSortOpen={setSortOpen}
97-
sortOpen={sortOpen}
98-
>
99-
{filtersOpen && (
100-
<DataActionsFilters
101-
chosenFilters={chosenFilters}
102-
setChosenFilters={setChosenFilters}
103-
closeFilters={closeFilters}
104-
options={filterOptions}
105-
title={filtersTitle}
106-
/>
107-
)}
108-
{sortOpen && (
109-
<DataActionsSorting
110-
chosenSorting={chosenSorting}
111-
setChosenSorting={setChosenSorting}
112-
closeSorts={closeSorts}
113-
options={sortOptions}
114-
/>
115-
)}
116-
</OrderActionsChip>
117-
</Box>
118-
</>
60+
<Box alignItems="center" display="flex" justifyContent="space-between">
61+
<InputBase
62+
inputProps={{ "data-testid": "search-input" }}
63+
onChange={(e) => setSearchText(e.target.value)}
64+
placeholder="Search..."
65+
value={searchText}
66+
startAdornment={
67+
<Search
68+
style={{
69+
color: "#99ADDE",
70+
height: 16,
71+
marginRight: 4,
72+
width: 16,
73+
}}
74+
/>
75+
}
76+
sx={{
77+
bgcolor: "white",
78+
border: 1,
79+
borderColor: "secondaryBlue",
80+
borderRadius: 50,
81+
boxShadow: `2px 2px 20px 0px ${boxShadow2}`,
82+
fontSize: 11,
83+
fontWeight: 500,
84+
height: 48,
85+
padding: "16px 24px",
86+
maxWidth: 500,
87+
}}
88+
/>
89+
<OrderActionsChip
90+
chosenFiltersLength={chosenFiltersLength}
91+
filtersOpen={filtersOpen}
92+
isFiltering={isFiltering}
93+
setFiltersOpen={setFiltersOpen}
94+
chosenSorting={chosenSorting}
95+
setSortOpen={setSortOpen}
96+
sortOpen={sortOpen}
97+
>
98+
{filtersOpen && (
99+
<DataActionsFilters
100+
chosenFilters={chosenFilters}
101+
setChosenFilters={setChosenFilters}
102+
closeFilters={closeFilters}
103+
options={filterOptions}
104+
title={filtersTitle}
105+
/>
106+
)}
107+
{sortOpen && (
108+
<DataActionsSorting
109+
chosenSorting={chosenSorting}
110+
setChosenSorting={setChosenSorting}
111+
closeSorts={closeSorts}
112+
options={sortOptions}
113+
/>
114+
)}
115+
</OrderActionsChip>
116+
</Box>
119117
);
120118
};

govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const DashboardGovernanceActions = () => {
9292

9393
const { state } = useLocation();
9494
const [content, setContent] = useState<number>(
95-
state && state.isVotedListOnLoad ? 1 : 0,
95+
state?.isVotedListOnLoad ? 1 : 0,
9696
);
9797

9898
const handleChange = (_event: React.SyntheticEvent, newValue: number) => {

govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ type StyledTabProps = {
4242
isMobile: boolean;
4343
};
4444

45-
const StyledTab = styled((props: StyledTabProps) => (
45+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
46+
const StyledTab = styled(({ isMobile, ...props }: StyledTabProps) => (
4647
<Tab disableRipple {...props} />
4748
))(({ isMobile }) => ({
4849
textTransform: "none",

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import { UseInfiniteQueryOptions } from "react-query";
2+
3+
import { Infinite, DRepData } from "@/models";
14
import { useGetDRepListInfiniteQuery } from "./useGetDRepListQuery";
25

36
export const useGetDRepDetailsQuery = (
47
dRepId: string | null | undefined,
5-
options?: { enabled: boolean },
8+
options?: UseInfiniteQueryOptions<Infinite<DRepData>>,
69
) => {
710
const { dRepData, isDRepListLoading } = useGetDRepListInfiniteQuery(
811
{ searchPhrase: dRepId ?? undefined },
9-
{ enabled: options?.enabled || !!dRepId },
12+
{ enabled: options?.enabled || !!dRepId, ...options },
1013
);
1114

1215
return { dRep: dRepData?.[0], isLoading: isDRepListLoading };

govtool/frontend/src/main.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ import pkg from "../package.json";
1616

1717
const { version } = pkg;
1818

19-
const queryClient = new QueryClient();
19+
const queryClient = new QueryClient({
20+
defaultOptions: {
21+
queries: {
22+
refetchOnWindowFocus: false,
23+
refetchOnMount: false,
24+
},
25+
},
26+
});
2027

2128
const tagManagerArgs = {
2229
gtmId: import.meta.env.VITE_GTM_ID,

0 commit comments

Comments
 (0)