-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix: remove unecessary calls to third party apis #9759
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Great catch!
|
Bitrise❌❌❌ Commit hash: 32e4d97 Note
|
Hey @legobeat ! I have this core PR for these updates MetaMask/core#4325 |
55d0584
to
54502e2
Compare
54502e2
to
6adfcac
Compare
Bitrise❌❌❌ Commit hash: 01c07f3 Note
|
Bitrise❌❌❌ Commit hash: 1256597 Note
|
4429c41
to
8458ea6
Compare
Bitrise❌❌❌ Commit hash: 8458ea6 Note
|
Bitrise✅✅✅ Commit hash: 0550366 Note
|
Bitrise❌❌❌ Commit hash: 131fbe8 Note
|
Bitrise✅✅✅ Commit hash: 3d201ce Note
|
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Description
The CollectibleContracts component was making more calls to the NFT API than it should.
Users could either have the nft detection enabled or disabled.
When the nft detection is enabled, the component was:
1- Executing
detectNfts
function which triggers one call to get all nfts for a user2- Calling
updateNftMetadata
which triggersN
number of calls to the NFT-API assuming the user hasN
NFT.The second call is unnecessary if the user already have the nftDetection enabled.
In this fix, i added a check in the useEffect to see if the user has the nftDetection enabled or not
If it is already enabled, calling the detectNfts function should be enough to refresh metadata.
When the user has the nftDetection Disabled, in this case the
updateNftMetadata
will be executed.I made an update in the
updateNftMetadata
fct to not execute the calls every time the user pulls down t refresh. A 10 mins interval should be enough.Note: We will have an update on the nftDetectionController in the future to update the polling strategy.
Related issues
Manual testing steps
To check the unecessary calls:
(See before video, notice on that wallet i have 5 nfts, it should be making only 1 call per nft => 5 calls in total but its making more than that. Every state update will result in the useEffect being executed which we attempt to avoid in this fix)
To check the update on this PR:
1- Build on this branch
2. Go to app/components/UI/CollectibleContracts/index.js and add a log inside useEffect
3. Go to node-modules, nftDetectionController.js function getOwnerNfts and add a console.log
4. Go to node-modules, nftController.js function getNftInformationFromApi and add a log
5. When you have nft detection disabled, go to nft tab, and pull down to refresh and check the calls made in your terminal
6. Enable nft detection, go to nft tab, pull down to refresh and check your logs
Screenshots/Recordings
Before
before4.mov
After
after.mov
Pre-merge author checklist
Pre-merge reviewer checklist