-
Notifications
You must be signed in to change notification settings - Fork 26
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
fix(frontend): fix hide zeros filter #4200
base: main
Are you sure you want to change the base?
Conversation
]; | ||
|
||
return checks.some((check) => check()); | ||
}; |
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.
can we not use the Number(balance ?? 0n) || (usdBalance ?? 0) || $showZeroBalances
logic? Will it not work?
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.
@AntonioVentilii you are right. This is much better
|
||
sortedTokensOrGroups = groupedTokens.filter((t: TokenUiOrGroupUi) => | ||
isTokenUiGroup(t) ? t.tokens.some((tok: TokenUi) => hasBalance(tok)) : hasBalance(t) | ||
); |
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.
can the above be put in an util, using reduce
with a few tests please?
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.
@AntonioVentilii i can put the code into an util and write some tests, but why should i use reduce
instead of filter
? Filtering is exactly what i want to do in this case
Motivation
If a user who is not invested in ck tokens activates the
Hide zeros
option, these tokens disappear. But the user should always know, that there is an option to invest in cks. This means if there is a token group and at least one of the tokens do have a balance, display the whole group.Changes
Tests
before:
after: