From 260c8c1e81ee5311d25796972d5d4bed830d2789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Mon, 17 Feb 2025 16:14:27 +0100 Subject: [PATCH] fix(#2994): fix refetching the drep directory --- CHANGELOG.md | 1 + .../components/molecules/DataActionsBar.tsx | 116 ++++++------ .../organisms/DashboardGovernanceActions.tsx | 2 +- .../GovernanceActionDetailsCardData.tsx | 3 +- .../hooks/queries/useGetDrepDetailsQuery.ts | 7 +- govtool/frontend/src/main.tsx | 9 +- govtool/frontend/yarn.lock | 174 +++++++++++++++++- 7 files changed, 246 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af0b046f9..1d0d26fce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ changes. - Fix crashing backend on unhandled missing proposal from vote [Issue 2920](https://github.com/IntersectMBO/govtool/issues/2920) - Remove abstain votes (not auto abstain) from total DRep stake - Fix counting committee members [Issue 2948](https://github.com/IntersectMBO/govtool/issues/2948) +- Fix refetching DRep list on every enter [Issue 2994](https://github.com/IntersectMBO/govtool/issues/2994) ### Changed diff --git a/govtool/frontend/src/components/molecules/DataActionsBar.tsx b/govtool/frontend/src/components/molecules/DataActionsBar.tsx index c2839ae78..223fef97e 100644 --- a/govtool/frontend/src/components/molecules/DataActionsBar.tsx +++ b/govtool/frontend/src/components/molecules/DataActionsBar.tsx @@ -57,64 +57,62 @@ export const DataActionsBar: FC = ({ ...props }) => { } = theme; return ( - <> - - setSearchText(e.target.value)} - placeholder="Search..." - value={searchText} - startAdornment={ - - } - sx={{ - bgcolor: "white", - border: 1, - borderColor: "secondaryBlue", - borderRadius: 50, - boxShadow: `2px 2px 20px 0px ${boxShadow2}`, - fontSize: 11, - fontWeight: 500, - height: 48, - padding: "16px 24px", - maxWidth: 500, - }} - /> - - {filtersOpen && ( - - )} - {sortOpen && ( - - )} - - - + + setSearchText(e.target.value)} + placeholder="Search..." + value={searchText} + startAdornment={ + + } + sx={{ + bgcolor: "white", + border: 1, + borderColor: "secondaryBlue", + borderRadius: 50, + boxShadow: `2px 2px 20px 0px ${boxShadow2}`, + fontSize: 11, + fontWeight: 500, + height: 48, + padding: "16px 24px", + maxWidth: 500, + }} + /> + + {filtersOpen && ( + + )} + {sortOpen && ( + + )} + + ); }; diff --git a/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx b/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx index 2efc90aa6..6c246b929 100644 --- a/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx +++ b/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx @@ -92,7 +92,7 @@ export const DashboardGovernanceActions = () => { const { state } = useLocation(); const [content, setContent] = useState( - state && state.isVotedListOnLoad ? 1 : 0, + state?.isVotedListOnLoad ? 1 : 0, ); const handleChange = (_event: React.SyntheticEvent, newValue: number) => { diff --git a/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx b/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx index 8b9d1048a..2419a77d4 100644 --- a/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx +++ b/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx @@ -42,7 +42,8 @@ type StyledTabProps = { isMobile: boolean; }; -const StyledTab = styled((props: StyledTabProps) => ( +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const StyledTab = styled(({ isMobile, ...props }: StyledTabProps) => ( ))(({ isMobile }) => ({ textTransform: "none", diff --git a/govtool/frontend/src/hooks/queries/useGetDrepDetailsQuery.ts b/govtool/frontend/src/hooks/queries/useGetDrepDetailsQuery.ts index 9bb53a206..3c99959ff 100644 --- a/govtool/frontend/src/hooks/queries/useGetDrepDetailsQuery.ts +++ b/govtool/frontend/src/hooks/queries/useGetDrepDetailsQuery.ts @@ -1,12 +1,15 @@ +import { UseInfiniteQueryOptions } from "react-query"; + +import { Infinite, DRepData } from "@/models"; import { useGetDRepListInfiniteQuery } from "./useGetDRepListQuery"; export const useGetDRepDetailsQuery = ( dRepId: string | null | undefined, - options?: { enabled: boolean }, + options?: UseInfiniteQueryOptions>, ) => { const { dRepData, isDRepListLoading } = useGetDRepListInfiniteQuery( { searchPhrase: dRepId ?? undefined }, - { enabled: options?.enabled || !!dRepId }, + { enabled: options?.enabled || !!dRepId, ...options }, ); return { dRep: dRepData?.[0], isLoading: isDRepListLoading }; diff --git a/govtool/frontend/src/main.tsx b/govtool/frontend/src/main.tsx index 76f6ff419..f9b4a9a7f 100644 --- a/govtool/frontend/src/main.tsx +++ b/govtool/frontend/src/main.tsx @@ -16,7 +16,14 @@ import pkg from "../package.json"; const { version } = pkg; -const queryClient = new QueryClient(); +const queryClient = new QueryClient({ + defaultOptions: { + queries: { + refetchOnWindowFocus: false, + refetchOnMount: false, + }, + }, +}); const tagManagerArgs = { gtmId: import.meta.env.VITE_GTM_ID, diff --git a/govtool/frontend/yarn.lock b/govtool/frontend/yarn.lock index 50ade3185..57c81b6d4 100644 --- a/govtool/frontend/yarn.lock +++ b/govtool/frontend/yarn.lock @@ -3229,6 +3229,11 @@ resolved "https://registry.npmjs.org/@types/jsonld/-/jsonld-1.5.15.tgz" integrity sha512-PlAFPZjL+AuGYmwlqwKEL0IMP8M8RexH0NIPGfCVWSQ041H2rR/8OlyZSD7KsCVoN8vCfWdtWDBxX8yBVP+xow== +"@types/katex@^0.16.0": + version "0.16.7" + resolved "https://registry.npmjs.org/@types/katex/-/katex-0.16.7.tgz" + integrity sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ== + "@types/lodash@^4.17.0": version "4.17.13" resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.13.tgz" @@ -7479,6 +7484,65 @@ hasown@^2.0.0, hasown@^2.0.1, hasown@^2.0.2: dependencies: function-bind "^1.1.2" +hast-util-from-dom@^5.0.0: + version "5.0.1" + resolved "https://registry.npmjs.org/hast-util-from-dom/-/hast-util-from-dom-5.0.1.tgz" + integrity sha512-N+LqofjR2zuzTjCPzyDUdSshy4Ma6li7p/c3pA78uTwzFgENbgbUrm2ugwsOdcjI1muO+o6Dgzp9p8WHtn/39Q== + dependencies: + "@types/hast" "^3.0.0" + hastscript "^9.0.0" + web-namespaces "^2.0.0" + +hast-util-from-html-isomorphic@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/hast-util-from-html-isomorphic/-/hast-util-from-html-isomorphic-2.0.0.tgz" + integrity sha512-zJfpXq44yff2hmE0XmwEOzdWin5xwH+QIhMLOScpX91e/NSGPsAzNCvLQDIEPyO2TXi+lBmU6hjLIhV8MwP2kw== + dependencies: + "@types/hast" "^3.0.0" + hast-util-from-dom "^5.0.0" + hast-util-from-html "^2.0.0" + unist-util-remove-position "^5.0.0" + +hast-util-from-html@^2.0.0: + version "2.0.3" + resolved "https://registry.npmjs.org/hast-util-from-html/-/hast-util-from-html-2.0.3.tgz" + integrity sha512-CUSRHXyKjzHov8yKsQjGOElXy/3EKpyX56ELnkHH34vDVw1N1XSQ1ZcAvTyAPtGqLTuKP/uxM+aLkSPqF/EtMw== + dependencies: + "@types/hast" "^3.0.0" + devlop "^1.1.0" + hast-util-from-parse5 "^8.0.0" + parse5 "^7.0.0" + vfile "^6.0.0" + vfile-message "^4.0.0" + +hast-util-from-parse5@^8.0.0: + version "8.0.2" + resolved "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-8.0.2.tgz" + integrity sha512-SfMzfdAi/zAoZ1KkFEyyeXBn7u/ShQrfd675ZEE9M3qj+PMFX05xubzRyF76CCSJu8au9jgVxDV1+okFvgZU4A== + dependencies: + "@types/hast" "^3.0.0" + "@types/unist" "^3.0.0" + devlop "^1.0.0" + hastscript "^9.0.0" + property-information "^6.0.0" + vfile "^6.0.0" + vfile-location "^5.0.0" + web-namespaces "^2.0.0" + +hast-util-is-element@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-3.0.0.tgz" + integrity sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g== + dependencies: + "@types/hast" "^3.0.0" + +hast-util-parse-selector@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-4.0.0.tgz" + integrity sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A== + dependencies: + "@types/hast" "^3.0.0" + hast-util-to-jsx-runtime@^2.0.0: version "2.3.2" resolved "https://registry.npmjs.org/hast-util-to-jsx-runtime/-/hast-util-to-jsx-runtime-2.3.2.tgz" @@ -7500,6 +7564,16 @@ hast-util-to-jsx-runtime@^2.0.0: unist-util-position "^5.0.0" vfile-message "^4.0.0" +hast-util-to-text@^4.0.0: + version "4.0.2" + resolved "https://registry.npmjs.org/hast-util-to-text/-/hast-util-to-text-4.0.2.tgz" + integrity sha512-KK6y/BN8lbaq654j7JgBydev7wuNMcID54lkRav1P0CaE1e47P72AWWPiGKXTJU271ooYzcvTAn/Zt0REnvc7A== + dependencies: + "@types/hast" "^3.0.0" + "@types/unist" "^3.0.0" + hast-util-is-element "^3.0.0" + unist-util-find-after "^5.0.0" + hast-util-whitespace@^2.0.0: version "2.0.1" resolved "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-2.0.1.tgz" @@ -7512,6 +7586,17 @@ hast-util-whitespace@^3.0.0: dependencies: "@types/hast" "^3.0.0" +hastscript@^9.0.0: + version "9.0.0" + resolved "https://registry.npmjs.org/hastscript/-/hastscript-9.0.0.tgz" + integrity sha512-jzaLBGavEDKHrc5EfFImKN7nZKKBdSLIdGvCwDZ9TfzbF2ffXiov8CKE445L2Z1Ek2t/m4SKQ2j6Ipv7NyUolw== + dependencies: + "@types/hast" "^3.0.0" + comma-separated-tokens "^2.0.0" + hast-util-parse-selector "^4.0.0" + property-information "^6.0.0" + space-separated-tokens "^2.0.0" + he@^1.2.0: version "1.2.0" resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz" @@ -9464,6 +9549,13 @@ jsonpointer@^5.0.0: object.assign "^4.1.4" object.values "^1.1.6" +katex@^0.16.0, katex@^0.16.21: + version "0.16.21" + resolved "https://registry.npmjs.org/katex/-/katex-0.16.21.tgz" + integrity sha512-XvqR7FgOHtWupfMiigNzmh+MgUVmDGU2kXZm899ZkPfcuoPuFxyHmXsgATDpFZDAXCI8tvinaVcDo8PIIJSo4A== + dependencies: + commander "^8.3.0" + keen-slider@^6.8.5: version "6.8.6" resolved "https://registry.npmjs.org/keen-slider/-/keen-slider-6.8.6.tgz" @@ -9845,6 +9937,19 @@ mdast-util-from-markdown@^2.0.0: micromark-util-types "^2.0.0" unist-util-stringify-position "^4.0.0" +mdast-util-math@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/mdast-util-math/-/mdast-util-math-3.0.0.tgz" + integrity sha512-Tl9GBNeG/AhJnQM221bJR2HPvLOSnLE/T9cJI9tlc6zwQk2nPk/4f0cHkOdEixQPC/j8UtKDdITswvLAy1OZ1w== + dependencies: + "@types/hast" "^3.0.0" + "@types/mdast" "^4.0.0" + devlop "^1.0.0" + longest-streak "^3.0.0" + mdast-util-from-markdown "^2.0.0" + mdast-util-to-markdown "^2.1.0" + unist-util-remove-position "^5.0.0" + mdast-util-mdx-expression@^2.0.0: version "2.0.1" resolved "https://registry.npmjs.org/mdast-util-mdx-expression/-/mdast-util-mdx-expression-2.0.1.tgz" @@ -9924,7 +10029,7 @@ mdast-util-to-hast@^13.0.0: unist-util-visit "^5.0.0" vfile "^6.0.0" -mdast-util-to-markdown@^2.0.0: +mdast-util-to-markdown@^2.0.0, mdast-util-to-markdown@^2.1.0: version "2.1.2" resolved "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz" integrity sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA== @@ -10063,6 +10168,19 @@ micromark-core-commonmark@^2.0.0: micromark-util-symbol "^2.0.0" micromark-util-types "^2.0.0" +micromark-extension-math@^3.0.0: + version "3.1.0" + resolved "https://registry.npmjs.org/micromark-extension-math/-/micromark-extension-math-3.1.0.tgz" + integrity sha512-lvEqd+fHjATVs+2v/8kg9i5Q0AP2k85H0WUOwpIVvUML8BapsMvh1XAogmQjOCsLpoKRCVQqEkQBB3NhVBcsOg== + dependencies: + "@types/katex" "^0.16.0" + devlop "^1.0.0" + katex "^0.16.0" + micromark-factory-space "^2.0.0" + micromark-util-character "^2.0.0" + micromark-util-symbol "^2.0.0" + micromark-util-types "^2.0.0" + micromark-factory-destination@^1.0.0: version "1.1.0" resolved "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-1.1.0.tgz" @@ -11069,7 +11187,7 @@ parse-passwd@^1.0.0: resolved "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz" integrity sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q== -parse5@^7.1.2: +parse5@^7.0.0, parse5@^7.1.2: version "7.2.1" resolved "https://registry.npmjs.org/parse5/-/parse5-7.2.1.tgz" integrity sha512-BuBYQYlv1ckiPdQi/ohiivi9Sagc9JG+Ozs0r7b/0iK3sKmrb0b9FdWdBbOdx6hBCM/F9Ir82ofnBhtZOjCRPQ== @@ -12453,6 +12571,19 @@ regjsparser@^0.12.0: dependencies: jsesc "~3.0.2" +rehype-katex@^7.0.1: + version "7.0.1" + resolved "https://registry.npmjs.org/rehype-katex/-/rehype-katex-7.0.1.tgz" + integrity sha512-OiM2wrZ/wuhKkigASodFoo8wimG3H12LWQaH8qSPVJn9apWKFSH3YOCtbKpBorTVw/eI7cuT21XBbvwEswbIOA== + dependencies: + "@types/hast" "^3.0.0" + "@types/katex" "^0.16.0" + hast-util-from-html-isomorphic "^2.0.0" + hast-util-to-text "^4.0.0" + katex "^0.16.0" + unist-util-visit-parents "^6.0.0" + vfile "^6.0.0" + relateurl@^0.2.7: version "0.2.7" resolved "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz" @@ -12465,6 +12596,16 @@ release-zalgo@^1.0.0: dependencies: es6-error "^4.0.1" +remark-math@^6.0.0: + version "6.0.0" + resolved "https://registry.npmjs.org/remark-math/-/remark-math-6.0.0.tgz" + integrity sha512-MMqgnP74Igy+S3WwnhQ7kqGlEerTETXMvJhrUzDikVZ2/uogJCb+WHUg97hK9/jcfc0dkD73s3LN8zU49cTEtA== + dependencies: + "@types/mdast" "^4.0.0" + mdast-util-math "^3.0.0" + micromark-extension-math "^3.0.0" + unified "^11.0.0" + remark-parse@^10.0.0: version "10.0.2" resolved "https://registry.npmjs.org/remark-parse/-/remark-parse-10.0.2.tgz" @@ -14170,6 +14311,14 @@ unique-string@^2.0.0: dependencies: crypto-random-string "^2.0.0" +unist-util-find-after@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/unist-util-find-after/-/unist-util-find-after-5.0.0.tgz" + integrity sha512-amQa0Ep2m6hE2g72AugUItjbuM8X8cGQnFoHk0pGfrFeT9GZhzN5SW8nRsiGKK7Aif4CrACPENkA6P/Lw6fHGQ== + dependencies: + "@types/unist" "^3.0.0" + unist-util-is "^6.0.0" + unist-util-generated@^2.0.0: version "2.0.1" resolved "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-2.0.1.tgz" @@ -14203,6 +14352,14 @@ unist-util-position@^5.0.0: dependencies: "@types/unist" "^3.0.0" +unist-util-remove-position@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-5.0.0.tgz" + integrity sha512-Hp5Kh3wLxv0PHj9m2yZhhLt58KzPtEYKQQ4yxfYFEO7EvHwzyDYnduhHnY1mDxoqr7VUwVuHXk9RXKIiYS1N8Q== + dependencies: + "@types/unist" "^3.0.0" + unist-util-visit "^5.0.0" + unist-util-stringify-position@^3.0.0: version "3.0.3" resolved "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-3.0.3.tgz" @@ -14399,6 +14556,14 @@ vary@~1.1.2: resolved "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz" integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== +vfile-location@^5.0.0: + version "5.0.3" + resolved "https://registry.npmjs.org/vfile-location/-/vfile-location-5.0.3.tgz" + integrity sha512-5yXvWDEgqeiYiBe1lbxYF7UMAIm/IcopxMHrMQDq3nvKcjPKIhZklUKL+AE7J7uApI4kwe2snsK+eI6UTj9EHg== + dependencies: + "@types/unist" "^3.0.0" + vfile "^6.0.0" + vfile-message@^3.0.0: version "3.1.4" resolved "https://registry.npmjs.org/vfile-message/-/vfile-message-3.1.4.tgz" @@ -14577,6 +14742,11 @@ wbuf@^1.1.0, wbuf@^1.7.3: dependencies: minimalistic-assert "^1.0.0" +web-namespaces@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz" + integrity sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ== + web-streams-polyfill@^3.0.3, web-streams-polyfill@>=3.2.1: version "3.3.3" resolved "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz"