fix: default image when nft to send has no image#580
Conversation
WalkthroughThe pull request introduces error handling improvements for NFT image loading across two Vue components. In Changes
Sequence DiagramsequenceDiagram
participant Component as NFT Select Component
participant Image as Image Resource
participant ErrorHandler as imageLoadError Method
Component->>Image: Attempt to load image
alt Image loads successfully
Image-->>Component: Render image
else Image fails to load
Image->>ErrorHandler: Trigger @error event
ErrorHandler-->>Component: Handle image loading failure
end
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|
💼 Build Files |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/extension/src/providers/common/ui/send-transaction/nft-select-list/components/nft-select-list-item.vue (1)
4-4: Consider adding fallback image src and loading stateWhile the error handling is good, consider these improvements for better user experience:
- Add a default/fallback src attribute
- Add loading state indication
- Add alt text for accessibility
- <img :src="item.image" @error="imageLoadError" /> + <img + :src="item.image" + :alt="item.name" + @error="imageLoadError" + loading="lazy" + />
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/extension/src/providers/common/ui/send-transaction/nft-select-list/components/nft-select-list-item.vue(2 hunks)packages/extension/src/providers/common/ui/send-transaction/send-nft-select.vue(2 hunks)
🔇 Additional comments (2)
packages/extension/src/providers/common/ui/send-transaction/send-nft-select.vue (1)
5-5:
Default image implementation is missing
The PR's objective is to "fix default image when nft to send has no image", but the implementation doesn't specify a default image source. The imageLoadError handler should set a fallback image when the NFT image fails to load.
Let's verify if a default image exists in the codebase:
Please ensure that the imageLoadError utility function sets an appropriate default image source. If you need help implementing this, I can provide guidance on adding a default image asset and updating the error handler.
packages/extension/src/providers/common/ui/send-transaction/nft-select-list/components/nft-select-list-item.vue (1)
29-29: Verify imageLoadError utility implementation
Let's ensure the utility properly handles the image error case.
✅ Verification successful
imageLoadError utility is properly implemented and widely used
The utility is correctly implemented in packages/extension/src/ui/action/utils/misc.ts and sets a fallback image when image loading fails. This is consistently used across multiple components in the codebase for handling failed image loads, including NFT images, token logos, and other assets. The implementation in the reviewed file follows the established pattern.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check implementation of imageLoadError utility
rg -A 5 "export.*imageLoadError.*=" src/
Length of output: 87
Script:
#!/bin/bash
# Search for imageLoadError implementation in the entire repository
rg -A 5 "export.*imageLoadError.*=" packages/
# Also search for any usage of imageLoadError
rg "imageLoadError" packages/
Length of output: 3209
Summary by CodeRabbit
New Features
Bug Fixes