fix: Account names should use natural sort order#1663
Open
alfiedotwtf wants to merge 2 commits intomasterfrom
Open
fix: Account names should use natural sort order#1663alfiedotwtf wants to merge 2 commits intomasterfrom
alfiedotwtf wants to merge 2 commits intomasterfrom
Conversation
4301f84 to
571137c
Compare
helciofranco
requested changes
Dec 9, 2024
Member
helciofranco
left a comment
There was a problem hiding this comment.
Good catch! Could we apply these two suggestions?
Comment on lines
+35
to
+40
| const collator = new Intl.Collator(undefined, { | ||
| numeric: true, | ||
| sensitivity: "base" | ||
| }); | ||
|
|
||
| accounts = accounts.sort((a, b) => collator.compare(a.name, b.name)); |
Member
There was a problem hiding this comment.
can we move this to AccountService.getAccounts?
so we fix the issue at the best place where the incorrect order is being returned
fuels-wallet/packages/app/src/systems/Account/services/account.ts
Lines 66 to 70 in 4fe865a
you'll need to use toArray() instead of toCollection() in order to run .sort() on it (and that sortBy('name') can be removed).
I think this approach might work:
static async getAccounts() {
return db.transaction('r', db.accounts, async () => {
const accounts = await db.accounts.toArray();
return accounts.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }));
});
}|
|
||
| accounts = accounts.sort((a, b) => collator.compare(a.name, b.name)); | ||
|
|
||
| return ( |
Member
There was a problem hiding this comment.
also, could you add a short and clear changelog for this fix?
just run pnpm changeset and follow the instruction (it looks like a patch fix)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When you have accounts
Account 1... all the way toAccount 15, the list ends up looking like this:etc.
This change makes the accounts list look like this: