-
Notifications
You must be signed in to change notification settings - Fork 145
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: NFTCard Displayed images that should not be displayed after swit… #549
fix: NFTCard Displayed images that should not be displayed after swit… #549
Conversation
🦋 Changeset detectedLatest commit: fbffee5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
packages/web3/src/hooks/useNFT.ts
Outdated
@@ -26,6 +37,9 @@ export default function useNFT( | |||
tokenId: BigInt(tokenId), | |||
}) | |||
.then((data) => { | |||
if (findChainIndex(availableChains as Chain[], chain as Chain) > 1) { |
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.
感觉这样实现不是很好,应该这样搞:
- 链切换的时候 chain 发生改变,这个时候重新调用 getNFTMetadata 请求新的数据
- 调用 getNFTMetadata 失败后显示 fallback image 就行
这样从逻辑上更符合实际情况。
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.
但是getNFTMetadata 的入参address与tokenId是固定的如何控制使getNFTMetadata 失败呢
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.
没失败的情况就正常显示就好,一般切换链的情况下 address 如果不修改的话就请求不到数据了,就会失败。
不是我们要控制 getNFTMetadata 去失败,是 getNFTMetadata 失败的情况下显示 fallback 的图片就行。
你随便写一个错误的 address 应该就能模拟这种情况。
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.
done
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #549 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 96 102 +6
Lines 4377 4802 +425
Branches 453 507 +54
==========================================
+ Hits 4377 4802 +425 ☔ View full report in Codecov by Sentry. |
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.
需要增加一个测试用例测试一下这种情况
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.
再帮忙补一个测试样例吧
#539