-
-
Notifications
You must be signed in to change notification settings - Fork 248
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/accounts tab search does not work correctly with special chars #14600
base: develop
Are you sure you want to change the base?
Fix/accounts tab search does not work correctly with special chars #14600
Conversation
86b8b35
to
bd936ca
Compare
Hello @mempoolboy , Thank you for your contribution! Thanks |
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 love this improvement, we were missing it, thank you! 🎉
Codewise looking good, I have only small codestyle nits 🙂
Tested locally rebased on develop, and works as expected ✔️
Note: there is conflict in one file, but it's trivial, so no need to re-review after solving it.
|
||
return translationString('LABELING_ACCOUNT', { | ||
networkName: translationString(getTitleForNetwork(symbol)), // Bitcoin, Ethereum, ... | ||
index: index + 1, // This is the number which shows after hash, e.g. Ethereum #3 |
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.
Nit: I know this line was copied as is from the old function, but we could make it neater 🙂
I'd extract index+1
as a variable, could be named for example displayedAccountNumber
or something, then comment is not needed. Code that explains itself is preferred over commentary, but it's a tiny thing 🙂
@@ -82,7 +81,7 @@ export const AccountDetails = ({ selectedAccount, isBalanceShown }: AccountDetai | |||
const [shouldAnimate, setShouldAnimate] = useState(false); | |||
const [hasMounted, setHasMounted] = useState(false); | |||
const selectedAccountLabels = useSelector(selectLabelingDataForSelectedAccount); | |||
const { defaultAccountLabelString } = useAccountLabel(); | |||
const { getDefaultAccountLabel } = useDefaultAccountLabel(); |
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.
thanks for renaming the returned callback, the old name didn't make much sense 👍
import { useTranslation } from './useTranslation'; | ||
import { AccountType, NetworkSymbol } from '@suite-common/wallet-config'; | ||
|
||
export interface GetDefaultAccountLabel { |
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.
Nit: I think GetDefaultAccountLabelParams
would be more suitable, because this isn't type of the function, just its params.
? list.filter(account => { | ||
const { key, accountType, symbol, index } = account; | ||
const accountLabel = | ||
accountLabels[key] || getDefaultAccountLabel({ accountType, symbol, index }); |
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.
Nit: this is imho more semantic - although it's longer, it makes it clear we're not checking for truthiness, but if the value exists on the record at all. Though this code is also fine 👌
accountLabels[key] || getDefaultAccountLabel({ accountType, symbol, index }); | |
accountLabels.hasOwnProperty(key) ? accountLabels[key] : getDefaultAccountLabel({ accountType, symbol, index }); |
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 really like this solution. 🤩
const accountLabel = | ||
accountLabels[key] || getDefaultAccountLabel({ accountType, symbol, index }); | ||
|
||
return accountSearchFn(account, searchString, coinFilter, accountLabel); |
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'd add a test case for this at accountUtils.test.ts#L217.
Although the accountSearchFn
function is itself unchanged, its usage has slightly changed. There is now no test case to match substring with supplied label, only whole string.
This will test it, and at the same time it'll help describe what is the fn typically used for 🙂
expect(accountSearchFn(btcAcc, '#1', undefined, 'Bitcoin #1')).toBe(true);
…ts in search as are used for rendering of accounts list
…nto a single return statement
bd936ca
to
5be1adc
Compare
Thanks for the thorough CR, it's much needed and appreciated. 😃 I've rebased the branch, resolved the conflict, addressed the issues and added the test scenario (well, I've rebased the branch and resolved the conflict 😄). |
Unlabeled accounts are represented by default labels created as translation strings. As these are derived from account data based on user settings and require an intl provider, they are not saved in the store and therefore are not included in the search).
Description
Include default labels in subject of account search, consolidate and refactor related code.
Related Issue
Resolve #11383
Screenshots: