Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Claim bug fixes #2362

Merged
merged 9 commits into from
Feb 3, 2022
Merged

Claim bug fixes #2362

merged 9 commits into from
Feb 3, 2022

Conversation

nenadV91
Copy link
Contributor

@nenadV91 nenadV91 commented Jan 31, 2022

Summary

This fixes few existing errors in console

  • issue with key props
    Screenshot from 2022-01-31 14-29-27

  • issue with calling fetch deployment timestamp multiple times and also memory leak issues
    Screenshot from 2022-01-31 15-55-40

  • issue with flashing screen before loader shows up

To test

  • we should test the rest of the claim functionality to make sure everything still works as expected

Edited anxo:
Just some test. Pls nenad ignore

LINEAR-13

@nenadV91 nenadV91 requested review from alfetopito, anxolin and elena-zh and removed request for anxolin January 31, 2022 19:10
@github-actions
Copy link
Contributor

  • 🔭 GP Swap: CoW Protocol v2 Swap UI

@@ -279,6 +279,17 @@ export function useUserClaims(account: Account, optionalChainId?: SupportedChain
return { claims: claimKey ? claimInfo[claimKey] : null, isLoading }
}

let FETCH_DEPLOYMENT_TIMESTAMP_PROMISE: Promise<number> | null = null
Copy link
Contributor

Choose a reason for hiding this comment

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

why CAPITAL letters if its not a constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same thing they used here

let FETCH_CLAIM_MAPPING_PROMISE: Promise<ClaimAddressMapping> | null = null

Copy link
Contributor

Choose a reason for hiding this comment

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

well, it sounds like also bad there :)

anyways, just a nit. Constants are capitalised, but this is not one

function fetchDeploymentTimestamp(vCowContract: VCowType) {
return (
FETCH_DEPLOYMENT_TIMESTAMP_PROMISE ??
(FETCH_DEPLOYMENT_TIMESTAMP_PROMISE = vCowContract.deploymentTimestamp().then((ts) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use await?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would keep then here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not against it, but any reason in particular?
it seems more readable to use await

@elena-zh
Copy link

elena-zh commented Feb 1, 2022

Hey @nenadV91 , I see an infinite loader when I open the Claim page as a not connected user:
image

@nenadV91
Copy link
Contributor Author

nenadV91 commented Feb 1, 2022

@elena-zh Good catch, should be fixed now.

@elena-zh
Copy link

elena-zh commented Feb 1, 2022

@nenadV91 , works fine.
I have encountered this UI issue on your PR:
image
In Staging it looks fine.
Could you please fix it?

@nenadV91 nenadV91 changed the base branch from release/1.10 to develop February 1, 2022 19:21
@@ -288,17 +304,28 @@ function useDeploymentTimestamp(): number | null {
const { chainId } = useActiveWeb3React()
const vCowContract = useVCowContract()
const [timestamp, setTimestamp] = useState<number | null>(null)
const [isMounted, setIsMounted] = useState(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should use a useRef instead.
Otherwise the isMounted flag will cause the issue you are trying to prevent here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion, looks like its working great.

@nenadV91 nenadV91 changed the base branch from develop to release/1.10 February 2, 2022 17:05
Copy link
Contributor

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

Approved but keep in mind now that you changed the base branch git thinks you are adding a bunch of commits you didn't do.

Either rebase/cherry-pick against release branch or merge it to sync the history

console.log('vCowContract Deployment Timestamp fetch failed')
}
})
}, [chainId, isMounted, timestamp, vCowContract])
Copy link
Contributor

Choose a reason for hiding this comment

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

It's still depending on timestamp from outer context which it shouldn't

Copy link
Contributor

@anxolin anxolin left a comment

Choose a reason for hiding this comment

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

SOFT approve.

Make sure you fix the base branch / commits before merging.

git rebase --onto would help. Otherwise cherry-pick

@@ -279,6 +279,17 @@ export function useUserClaims(account: Account, optionalChainId?: SupportedChain
return { claims: claimKey ? claimInfo[claimKey] : null, isLoading }
}

let FETCH_DEPLOYMENT_TIMESTAMP_PROMISE: Promise<number> | null = null
Copy link
Contributor

Choose a reason for hiding this comment

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

well, it sounds like also bad there :)

anyways, just a nit. Constants are capitalised, but this is not one

@nenadV91 nenadV91 force-pushed the claim-bug-fixes branch 2 times, most recently from ca1caa2 to abd4025 Compare February 3, 2022 10:21
* Creates a ref that can be used to solve the issue of
* "Can't perform a React state update on an unmounted component."
*/
function useIsMounted() {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not do this in a more general place and export it. Its a general solution, right?

@nenadV91 nenadV91 merged commit 886cdf4 into release/1.10 Feb 3, 2022
@alfetopito alfetopito deleted the claim-bug-fixes branch February 3, 2022 17:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants