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

UX: Fix token image not displaying in asset listing #17575

Merged
merged 3 commits into from Feb 6, 2023

Conversation

darkwing
Copy link
Contributor

@darkwing darkwing commented Feb 2, 2023

Explanation

Tokens that we do have icons for sometimes don't display that icon in the token listing -- instead, a JazzIcon or Blockie displays. When clicking into the token's detail screen, the correct image does display. We weren't taking advantage of the image being passed in, which I've fixed.

One side effect of fixing the original problem is that a token for which we don't have an icon for shows a 404 icon, which is a problem. I've fixed this by showing a JazzIcon or Blockie if the image errors.

Screenshots/Screencaps

GoodIcon

Manual Testing Steps

  1. Add Binance Smart Chain if you don't already have it
  2. Import token 0xe4fae3faa8300810c835970b9187c268f55d998f
  3. Previously, a Blockie/JazzIcon would display -- now you'll see the correct icon
  4. Switch to MainNet
  5. Import the same token address -- this would have shown a 404 image
  6. Now see that the Blockie/JazzIcon displays

Pre-merge author checklist

  • I've clearly explained:
    • What problem this PR is solving
    • How this problem was solved
    • How reviewers can test my changes
  • Sufficient automated test coverage has been added

Pre-merge reviewer checklist

  • Manual testing (e.g. pull and build branch, run in browser, test code being changed)
  • PR is linked to the appropriate GitHub issue
  • IF this PR fixes a bug in the release milestone, add this PR to the release milestone

If further QA is required (e.g. new feature, complex testing steps, large refactor), add the Extension QA Board label.

In this case, a QA Engineer approval will be be required.

@darkwing darkwing requested a review from a team as a code owner February 2, 2023 17:52
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2023

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.

@@ -93,6 +97,10 @@ export default class Identicon extends Component {
src={image}
style={getStyles(diameter)}
alt={alt}
onError={() => {
this.setState({ imageLoadingError: true });
this.forceUpdate();
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 absolutely loathe this but simply updating state doesn't cause a re-render

Copy link
Contributor

Choose a reason for hiding this comment

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

TIL about forceUpdate

Copy link
Member

Choose a reason for hiding this comment

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

The reason is because of the shouldComponentUpdate only compares props.

Copy link
Member

Choose a reason for hiding this comment

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

the second prop to shouldComponentUpdate is nextState

dan437
dan437 previously approved these changes Feb 2, 2023
Copy link
Contributor

@dan437 dan437 left a comment

Choose a reason for hiding this comment

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

Awesome, I've followed test instructions and it seems to be working now. I will re-approve it once a lint issue is solved.

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Tested on local. LGTM!

@metamaskbot
Copy link
Collaborator

Builds ready [48c8365]
Page Load Metrics (1269 ± 103 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint104167130188
domContentLoaded9911725125620598
load99117251269215103
domInteractive9911725125620598
Bundle size diffs
  • background: 0 bytes
  • ui: 332 bytes
  • common: 0 bytes

dan437
dan437 previously approved these changes Feb 3, 2023
@@ -93,6 +97,10 @@ export default class Identicon extends Component {
src={image}
style={getStyles(diameter)}
alt={alt}
onError={() => {
this.setState({ imageLoadingError: true });
this.forceUpdate();
Copy link
Member

Choose a reason for hiding this comment

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

The reason is because of the shouldComponentUpdate only compares props.

@@ -93,6 +97,10 @@ export default class Identicon extends Component {
src={image}
style={getStyles(diameter)}
alt={alt}
onError={() => {
this.setState({ imageLoadingError: true });
this.forceUpdate();
Copy link
Member

Choose a reason for hiding this comment

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

the second prop to shouldComponentUpdate is nextState

@darkwing darkwing dismissed stale reviews from dan437 and georgewrmarshall via 1c2fa08 February 3, 2023 18:35
@metamaskbot
Copy link
Collaborator

Builds ready [1c2fa08]
Page Load Metrics (1281 ± 114 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint912451294120
domContentLoaded99816631271230111
load99816631281237114
domInteractive99816631271230111
Bundle size diffs
  • background: 0 bytes
  • ui: 345 bytes
  • common: 0 bytes

@darkwing darkwing merged commit 02d608d into develop Feb 6, 2023
@darkwing darkwing deleted the fix-asset-list-image branch February 6, 2023 14:31
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2023
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.

None yet

6 participants