Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

feature: EthHashInfo add customAvatar fallback #123

Merged
merged 6 commits into from
Apr 26, 2021

Conversation

nicosampler
Copy link
Contributor

@nicosampler nicosampler commented Apr 23, 2021

We need to handle the case for when customAvatar is broken.

  • I added a new property called customAvatarFallaback that receives an URL to callback in case the main image is broken
  • I no customAvatarFallaback was provided it fallback to Identicon.

These changes are needed for https://app.zenhub.com/workspaces/safe-multisig---web-5ce554debb310a35b2f8b6f8/issues/gnosis/safe-react/2133

@nicosampler nicosampler self-assigned this Apr 23, 2021
@github-actions
Copy link

github-actions bot commented Apr 23, 2021

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 1 0
Ignored 0 N/A
  • Result: ✅ success

  • Annotations: 1 total


[warning] @typescript-eslint/no-unused-vars

Disallow unused variables


Report generated by eslint-plus-action

@ghost
Copy link

ghost commented Apr 23, 2021

Travis automatic deployment:
https://pr123--safereactcomponents.review.gnosisdev.com

1 similar comment
@ghost
Copy link

ghost commented Apr 23, 2021

Travis automatic deployment:
https://pr123--safereactcomponents.review.gnosisdev.com

@nicosampler nicosampler marked this pull request as ready for review April 23, 2021 19:13
): void => {
if (customAvatarFallback && !fallbackToIdenticon) {
error.currentTarget.onerror = null;
error.currentTarget.src = customAvatarFallback;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could avoid manipulating DOM directly?

setFallbackSrc(customAvatarFallback);

...

<StyledImg
  src={fallbackSrc || customAvatar}
  ...
/>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right, I copied it directly from SRC.
what do you suggest? ref perhpahs?

Copy link
Member

Choose a reason for hiding this comment

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

Just a state variable, see the code snippet in my previous comment.

@@ -54,6 +54,7 @@ type Props = {
textSize?: ThemeTextSize;
showAvatar?: boolean;
customAvatar?: string;
customAvatarFallback?: string;
Copy link
Member

Choose a reason for hiding this comment

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

Is this image always going to be the <> icon? If so, we could just store the SVG in the repo. Or at least use it as the default value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are 2 different repositories.
<> is needed at this moment in SRC, but as this lib is also helpful for SApp I would not use it as a default one.

@nicosampler nicosampler requested a review from katspaugh April 26, 2021 15:47
Copy link
Member

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

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

Thanks! Please update the snapshots.

@ghost
Copy link

ghost commented Apr 26, 2021

Travis automatic deployment:
https://pr123--safereactcomponents.review.gnosisdev.com

@nicosampler nicosampler merged commit 5a96910 into development Apr 26, 2021
@nicosampler nicosampler deleted the EthHashInfo-image-fallback branch April 26, 2021 17:36
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.

2 participants