feat: show voted indicator on governance proposals list#2950
feat: show voted indicator on governance proposals list#2950
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds a “You voted” indicator to each governance proposal row by propagating the connected user’s vote information through the proposals data adapters and hooks into the list UI.
Changes:
- Added a
userVotefield to the canonicalProposalListItemtype and populated it from both subgraph and cache data paths. - Updated proposal-fetching hooks/services to pass the connected user address so per-user voted info can be resolved.
- Rendered a “You voted YAE/NAY” badge in the proposals list row and updated Lingui message references.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/modules/governance/types.ts | Introduces UserVoteInfo and adds optional userVote to ProposalListItem. |
| src/modules/governance/adapters.ts | Maps subgraph/cache vote data into ProposalListItem.userVote. |
| src/modules/governance/ProposalsV3List.tsx | Renders the voted indicator in each proposal row. |
| src/locales/en/messages.po | Adds a source reference for the reused “You voted {0}” message. |
| src/hooks/governance/useProposals.ts | Threads optional user into fetchProposals and voting machine data fetch. |
| src/hooks/governance/useGovernanceProposals.ts | Fetches user votes (cache path) and keys/refetches queries by user address. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <SvgIcon sx={{ fontSize: 14 }}> | ||
| <CheckCircleIcon /> | ||
| </SvgIcon> |
There was a problem hiding this comment.
CheckCircleIcon from @heroicons/react renders an <svg> already; nesting it inside MUI's <SvgIcon> produces an <svg> inside another <svg>, which can cause sizing/styling issues and invalid markup. Prefer rendering the Heroicon directly (set height/width/color) or pass it via SvgIcon's component prop instead of as a child.
| const userVotes = user | ||
| ? await Promise.all( | ||
| proposals.map((p) => getUserVoteFromCache(p.id, user).catch(() => null)) | ||
| ) | ||
| : proposals.map(() => null); |
There was a problem hiding this comment.
This introduces an N+1 pattern: for each proposals page (PAGE_SIZE=10) it makes one getUserVoteFromCache request per proposal, which can add significant latency and load on the cache backend. Consider batching these lookups into a single GraphQL request (e.g., a bulk endpoint, or a single query using field aliases for each proposalId) so the page fetch remains O(1) requests.
| const userVotes = user | ||
| ? await Promise.all(results.map((p) => getUserVoteFromCache(p.id, user).catch(() => null))) | ||
| : results.map(() => null); | ||
| return results.map((p, i) => adaptCacheProposalToListItem(p, userVotes[i])); |
There was a problem hiding this comment.
Same N+1 issue in search: this does one getUserVoteFromCache request per search result. If the cache path remains enabled, batching user-vote lookups into a single request would keep search responsive and reduce backend load.
|
📦 Next.js Bundle Analysis for aave-uiThis analysis was generated by the Next.js Bundle Analysis action. 🤖 🎉 Global Bundle Size Decreased
DetailsThe global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster. Any third party scripts you have added directly to your app using the If you want further insight into what is behind the changes, give @next/bundle-analyzer a try! Sixteen Pages Changed SizeThe following pages changed size from the code in this PR compared to its base branch:
DetailsOnly the gzipped size is provided here based on an expert tip. First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If Any third party scripts you have added directly to your app using the Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. |
General Changes
Adds a you voted badge on the row
Developer Notes
Add any notes here that may be helpful for reviewers.
Reviewer Checklist
Please ensure you, as the reviewer(s), have gone through this checklist to ensure that the code changes are ready to ship safely and to help mitigate any downstream issues that may occur.
.env.examplefile as well as the pertinant.github/actions/*files