-
Notifications
You must be signed in to change notification settings - Fork 5k
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
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. |
@@ -93,6 +97,10 @@ export default class Identicon extends Component { | |||
src={image} | |||
style={getStyles(diameter)} | |||
alt={alt} | |||
onError={() => { | |||
this.setState({ imageLoadingError: true }); | |||
this.forceUpdate(); |
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.
I absolutely loathe this but simply updating state doesn't cause a re-render
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.
TIL about forceUpdate
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.
The reason is because of the shouldComponentUpdate only compares props.
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.
the second prop to shouldComponentUpdate is nextState
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.
Awesome, I've followed test instructions and it seems to be working now. I will re-approve it once a lint issue is solved.
8396749
to
d1ad653
Compare
d1ad653
to
48c8365
Compare
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.
Tested on local. LGTM!
Builds ready [48c8365]
Page Load Metrics (1269 ± 103 ms)
Bundle size diffs
|
@@ -93,6 +97,10 @@ export default class Identicon extends Component { | |||
src={image} | |||
style={getStyles(diameter)} | |||
alt={alt} | |||
onError={() => { | |||
this.setState({ imageLoadingError: true }); | |||
this.forceUpdate(); |
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.
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(); |
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.
the second prop to shouldComponentUpdate is nextState
1c2fa08
Builds ready [1c2fa08]
Page Load Metrics (1281 ± 114 ms)
Bundle size diffs
|
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
Manual Testing Steps
0xe4fae3faa8300810c835970b9187c268f55d998f
Pre-merge author checklist
Pre-merge reviewer checklist
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.