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

fix: NFTCard Displayed images that should not be displayed after swit… #549

Merged
merged 6 commits into from
Feb 18, 2024

Conversation

shanchuan1
Copy link
Contributor

Copy link

changeset-bot bot commented Feb 2, 2024

🦋 Changeset detected

Latest commit: fbffee5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@ant-design/web3 Patch

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

Copy link

vercel bot commented Feb 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ant-design-web3 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 18, 2024 7:14am

Copy link

github-actions bot commented Feb 2, 2024

@@ -26,6 +37,9 @@ export default function useNFT(
tokenId: BigInt(tokenId),
})
.then((data) => {
if (findChainIndex(availableChains as Chain[], chain as Chain) > 1) {
Copy link
Collaborator

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 就行

这样从逻辑上更符合实际情况。

Copy link
Contributor Author

@shanchuan1 shanchuan1 Feb 3, 2024

Choose a reason for hiding this comment

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

但是getNFTMetadata 的入参address与tokenId是固定的如何控制使getNFTMetadata 失败呢

Copy link
Collaborator

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 应该就能模拟这种情况。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link

codecov bot commented Feb 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (62262c8) 100.00% compared to head (fbffee5) 100.00%.
Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@kiner-tang kiner-tang left a comment

Choose a reason for hiding this comment

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

需要增加一个测试用例测试一下这种情况

Copy link
Collaborator

@yutingzhao1991 yutingzhao1991 left a comment

Choose a reason for hiding this comment

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

再帮忙补一个测试样例吧

@yutingzhao1991 yutingzhao1991 merged commit ae85fa9 into ant-design:main Feb 18, 2024
9 checks passed
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.

3 participants