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

Chore/sc 519/upgrade swr to 1 0 #244

Merged
merged 17 commits into from
Nov 19, 2021
Merged

Conversation

adamgoth
Copy link
Collaborator

Link to Clubhouse story

https://app.shortcut.com/dux-makerdao/story/519/upgrade-swr-to-1-0

What does this PR do?

Upgrades to SWR 1.0

Reduces default polling interval

Cuts down on unnecessary calls

Adds mutations (revalidation) where necessary

Steps for testing:

Check all the pages of the app. Send tests transactions. Look for anything funky.

Any additional helpful information?:

Reducing infura calls will be handled in a separate PR

Add a GIF:

@vercel
Copy link

vercel bot commented Nov 11, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/dux-core-unit/governance-portal-v2/A5eNxX5ZKF8zR3mmmQRiLdTqYTh3
✅ Preview: https://governance-portal-v2-git-chore-sc-519upgra-71e8d7-dux-core-unit.vercel.app

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #519: Upgrade SWR to 1.0.

@adamgoth adamgoth marked this pull request as ready for review November 12, 2021 17:13
@codecov
Copy link

codecov bot commented Nov 12, 2021

Codecov Report

Merging #244 (725f1dc) into develop (5f4b475) will increase coverage by 1.19%.
The diff coverage is 81.81%.

❗ Current head 725f1dc differs from pull request most recent head caef9f3. Consider uploading reports for the commit caef9f3 to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #244      +/-   ##
===========================================
+ Coverage    35.34%   36.53%   +1.19%     
===========================================
  Files           58       57       -1     
  Lines         1610     1593      -17     
  Branches       520      502      -18     
===========================================
+ Hits           569      582      +13     
+ Misses        1034     1004      -30     
  Partials         7        7              
Impacted Files Coverage Δ
pages/_app.tsx 0.00% <ø> (ø)
pages/esmodule.tsx 62.71% <ø> (ø)
pages/polling/[poll-hash].tsx 0.00% <0.00%> (ø)
lib/hooks/useDelegateAddressMap.ts 60.00% <100.00%> (ø)
pages/executive.tsx 57.66% <100.00%> (+11.34%) ⬆️
pages/polling.tsx 63.00% <100.00%> (+1.94%) ⬆️
lib/utils.ts 63.21% <0.00%> (-0.42%) ⬇️
lib/api/utils.ts 0.00% <0.00%> (ø)
lib/constants.ts 92.85% <0.00%> (ø)
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f4b475...caef9f3. Read the comment docs.

Copy link
Contributor

@rafinskipg rafinskipg left a comment

Choose a reason for hiding this comment

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

So it seems on the delegates page, if you freshload, it does not load the MKR delegated, but if you switch focus ( change to other app or tab) it does refresh the balances

@@ -1,4 +1,4 @@
### Link to Clubhouse story
### Link to Shortcut ticket:
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -8,7 +8,9 @@ type DelegateAddressMapResponse = {
};

export const useDelegateAddressMap = (): DelegateAddressMapResponse => {
const { data: delegatesApiResponse, error } = useSWR(`/api/delegates?network=${getNetwork()}`);
const { data: delegatesApiResponse, error } = useSWR(`/api/delegates?network=${getNetwork()}`, null, {
refreshInterval: 0
Copy link
Contributor

Choose a reason for hiding this comment

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

it means no refresh, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Exactly

@@ -68,6 +76,8 @@ export const DelegateModal = ({ isOpen, onDismiss, delegate }: Props): JSX.Eleme
const lockTxCreator = () => maker.service('voteDelegate').lock(voteDelegateAddress, mkrToDeposit);
const txId = await trackTransaction(lockTxCreator, 'Depositing MKR', {
mined: txId => {
mutateTotalStaked();
mutateMkrStaked();
Copy link
Contributor

Choose a reason for hiding this comment

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

If you close the modal does these mutates get triggered?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not on modal close. When we broadcast the tx, we track it through dai.js's transaction manager (through trackTranscation). That tracking function provides hooks for when the tx status changes. So as soon as we detect that the tx was mined, that's when those functions trigger.

`/api/executive/analyze-spell/${proposalAddress}?network=${getNetwork()}`
);

return {
data,
loading: !error && !data,
error
error,
mutate
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@adamgoth
Copy link
Collaborator Author

So it seems on the delegates page, if you freshload, it does not load the MKR delegated, but if you switch focus ( change to other app or tab) it does refresh the balances

Nice catch. Should be fixed now 🔨

@adamgoth adamgoth requested a review from rafinskipg November 18, 2021 19:57
@rafinskipg rafinskipg mentioned this pull request Nov 19, 2021
@rafinskipg rafinskipg merged commit 5f4df06 into develop Nov 19, 2021
@rafinskipg rafinskipg deleted the chore/sc-519/upgrade-swr-to-1-0 branch November 19, 2021 15:37
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.

2 participants