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

LIVE-4370 tron more explicit error #1962

Merged
merged 9 commits into from
Nov 29, 2022
Merged

Conversation

henri-ly
Copy link
Contributor

πŸ“ Description

Add learn more link to error message + add more explicit error for tron

❓ Context

  • Impacted projects: live-mobile, live-desktop
  • Linked resource(s): ``

βœ… Checklist

  • Test coverage
  • Atomic delivery
  • No breaking changes

πŸ“Έ Demo

Screenshot 2022-11-24 at 13 29 30

Screenshot 2022-11-24 at 14 47 54

Screenshot 2022-11-24 at 16 09 10

Screenshot 2022-11-24 at 17 56 38

πŸš€ Expectations to reach

Please make sure you follow these Important Steps.

Pull Requests must pass the CI and be internally validated in order to be merged.

@henri-ly henri-ly requested a review from a team as a code owner November 25, 2022 09:42
@changeset-bot
Copy link

changeset-bot bot commented Nov 25, 2022

πŸ¦‹ Changeset detected

Latest commit: a5223e2

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

This PR includes changesets to release 2 packages
Name Type
live-mobile Minor
ledger-live-desktop Minor

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

@github-actions github-actions bot added desktop Has changes in LLD mobile Has changes in LLM translations Translation files have been touched labels Nov 25, 2022
@vercel
Copy link

vercel bot commented Nov 25, 2022

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated
live-common-tools βœ… Ready (Inspect) Visit Preview Nov 29, 2022 at 2:21PM (UTC)
3 Ignored Deployments
Name Status Preview Updated
ledger-live-github-bot ⬜️ Ignored (Inspect) Nov 29, 2022 at 2:21PM (UTC)
native-ui-storybook ⬜️ Ignored (Inspect) Nov 29, 2022 at 2:21PM (UTC)
react-ui-storybook ⬜️ Ignored (Inspect) Nov 29, 2022 at 2:21PM (UTC)

hideToast();
}, [setIsAddionalInfoModalOpen, hideToast]);

const closeAdditionalInfoModal = useCallback(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be more careful with how we call useCallback, useMemo and such as it's sometimes more costly in performance to call it than not. It's not necessary here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just a copy paste of an existing file, I duplicate it because we want this error to be exclusive to tron, I have no idea what most of contains of the file is

Copy link

Choose a reason for hiding this comment

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

@lvndry I'm interested with this argument about performance, do you have details about it?

From what we've read, the benefit of using hooks all the time without thinking about it is mostly superior to the cost, cf. this explanation for instance: https://attardi.org/why-we-memo-all-the-things/

If you have doc stating otherwise feel free to share.

Copy link
Contributor

Choose a reason for hiding this comment

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

@haammar-ledger Yep this could be discussed outside of here but IMO hooks are tools to optimise (meaning making fast code, faster) and not a tool that improves performance (making slow code, fast).

My arguments against overusing hooks are:

  • Most of the time perfomance gains of useCallback or useMemo are basically unnoticeable but we still do function calls which impact our perf
  • More verbose codebase
  • This leads to the wrong idea that these hooks solve bigger performance issues, like thinking that as long as we wrap everything with useCallback, useMemo we don't have to care about things that actually have bigger like useless state change, useless rerenders, component composition, etc
  • The react doc states that useMemo might not use the memoized values everytime, it's not a guarantee so we should not rely on them by default

Here are some interesting blog posts:

https://kentcdodds.com/blog/usememo-and-usecallback
https://www.joshwcomeau.com/react/usememo-and-usecallback/
https://www.developerway.com/posts/how-to-use-memo-use-callback
https://maxrozen.com/understanding-when-use-usememo

Copy link
Contributor

@lambertkevin lambertkevin left a comment

Choose a reason for hiding this comment

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

I know most of the files are probably a copy/paste of another file, so feel free to ignore if we're in a hurry πŸ‘

/>
{verifyAddressError ? (
<ErrorDisplay error={verifyAddressError} onRetry={onVerify} />
) : isAddressVerified === true ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

The typing of isAddressVerified is kinda weird if we have to check true with strict equality πŸ€”
Same thing for the isAddressVerified === false just under.

I know .jsx is a pain in the ass for simple if/elseif/else, but all of those imbricated ternary operators are making me dizzy πŸ˜†

{
  verifyAddressError ? (
    A
   ) : isAddressVerified === true ? (
    B
   ) : isAddressVerified === false ? (
    C
   ) : device ? (
    D
  ) : null // should not happen <--- wut
}

And B & C are actually containing ternaries as well 🀯

Again nothing mandatory, but that would probably help to have a simple function with if/elseif/else outside of the templating imo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Weird stuff indeed. But yeah I'm too afraid at this point to change a thing on this file since most of the code doesn't belongs to me.

I can try if I have not other things to fix tho

@github-actions
Copy link

github-actions bot commented Nov 25, 2022

@henrily-ledger

Screenshots: βœ…

There are no changes in the screenshots for this PR. If this is expected, you are good to go.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

@henrily-ledger

) : null;

return (
<Text>
Copy link

Choose a reason for hiding this comment

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

Being extra careful here, but do you think <Text> can never change the display, depending on the context? I'm just wondering because of how TranslatedComponent is used in so many places...

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 don't think it can but we maybe need to be careful about this

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'll try to do an extra condition for not impacting unless we got a learn more

@codecov
Copy link

codecov bot commented Nov 25, 2022

Codecov Report

Base: 42.85% // Head: 42.85% // No change to project coverage πŸ‘

Coverage data is based on head (f7a769f) compared to base (89279e7).
Patch has no changes to coverable lines.

❗ Current head f7a769f differs from pull request most recent head a5223e2. Consider uploading reports for the commit a5223e2 to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1962   +/-   ##
========================================
  Coverage    42.85%   42.85%           
========================================
  Files          624      624           
  Lines        25895    25895           
  Branches      7159     7159           
========================================
  Hits         11098    11098           
  Misses       13640    13640           
  Partials      1157     1157           
Flag Coverage Ξ”
test 42.85% <ΓΈ> (ΓΈ)

Flags with carried forward coverage won't be shown. Click here to find out more.

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

β˜” View full report at Codecov.
πŸ“’ Do you have feedback about the report comment? Let us know in this issue.

@henri-ly henri-ly merged commit d96bcf1 into develop Nov 29, 2022
@henri-ly henri-ly deleted the feat/LIVE-4370-tron-errors-trc-20 branch November 29, 2022 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop Has changes in LLD mobile Has changes in LLM translations Translation files have been touched
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants