Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrate voting power to vue query #1220

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Feb 27, 2025

Summary

Closes: #939
Toward https://github.com/snapshot-labs/workflow/issues/410

This PR completes the refactoring process on the voting/proposing power composable, by migrating the remaining voting power composable/store to vue-query

This also fix an issue where any errors on either the proposing power or voting power would fail the entire fetching in the single multi-use composable.

How to test

  1. Go to a space's /proposals page
  2. It should show the voting power for the latest block
  3. Navigating internally to other page and coming back will load the cached VP
  4. Switching account will load the VP for the connected current account
  5. Go to a proposal page
  6. Test using same method as above
  7. Open a vote modal
  8. Changing between account which have/don't have VP will show the "not enough vp" error message
  9. Go to http://localhost:8080/#/s:gitcoindao.eth/proposals
  10. It should load the voting power without any errors (like on master)

@wa0x6e wa0x6e requested a review from Copilot February 27, 2025 00:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR refactors the voting power logic by migrating the voting power composable/store code to use vue-query, ensuring that errors from fetching voting power for both proposals and spaces are handled independently. Key changes include:

  • Replacing the legacy voting power store/composable with useQuery–based implementations in votingPower.ts.
  • Updating the Space/Proposals and Proposal views to use the new vue-query hooks.
  • Removing the old voting power store and composable files while updating related components and modals.

Reviewed Changes

File Description
apps/ui/src/queries/votingPower.ts Introduces vue-query-based fetching of voting power with new query keys.
apps/ui/src/views/Space/Proposals.vue Updates to use the new useSpaceVotingPowerQuery, removing legacy calls.
apps/ui/src/views/Proposal.vue Uses the new useProposalVotingPowerQuery, refactoring error and loading states.
apps/ui/src/stores/votingPowers.ts Entire file removed as part of the migration.
apps/ui/src/composables/useVotingPower.ts Entire file removed as part of the migration.
apps/ui/src/components/Modal/VotingPower.vue Adjusted imports and event names to match new voting power query usage.
apps/ui/src/components/Modal/Vote.vue Updated to utilize the new proposal voting power query.
apps/ui/src/components/IndicatorVotingPower.vue Refactored to use new props and imports from the updated voting power query.

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

@wa0x6e wa0x6e requested a review from Copilot February 27, 2025 20:19
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR refactors voting power logic by migrating from the previous composable/store implementation to use vue-query. Key changes include:

  • Introducing new queries in apps/ui/src/queries/votingPower.ts for retrieving voting power.
  • Updating components, views, and helper imports to use the new queries.
  • Removing the obsolete voting power store and composable files.

Reviewed Changes

File Description
apps/ui/src/queries/votingPower.ts Introduces voting power queries and related helper functions
apps/ui/src/helpers/utils.ts Updates import source of VotingPowerItem to the new queries
apps/ui/src/views/Space/Proposals.vue Replaces the old voting power composable with the new query hooks
apps/ui/src/views/Proposal.vue Replaces voting power fetching and handling with new query hooks
apps/ui/src/stores/votingPowers.ts Removes the obsolete voting power store
apps/ui/src/composables/useVotingPower.ts Removes the obsolete voting power composable
apps/ui/src/components/ProposalsListItem.vue Minor adjustment to conditionally render the vote modal
apps/ui/src/components/Modal/VotingPower.vue Updates props and event names to align with the new query implementation
apps/ui/src/components/Modal/Vote.vue Updates voting power handling to use the new query, including proper state
apps/ui/src/components/MessageVotingPower.vue Updates import source for VotingPowerItem to the new queries
apps/ui/src/components/IndicatorVotingPower.vue Updates props, import, and event to use the new voting power query setup

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

@wa0x6e wa0x6e marked this pull request as ready for review February 27, 2025 22:04
@wa0x6e wa0x6e requested a review from Sekhmet February 27, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor: move away from single voting power composable/store
1 participant