Skip to content

Commit 937a023

Browse files
committed
frontend/utils: sort getAccountsByKeystore map
The input accounts list seems to be possibly ordered differently in different places in the code (e.g. sidebar vs manage account page). This ensures that the list of accounts grouped by keystore always has a consistent order, and also keeps keystores with same name (e.g. create using different passphrases) to be close to each other in the list.
1 parent 70e8ea4 commit 937a023

File tree

1 file changed

+7
-1
lines changed
  • frontends/web/src/routes/account

1 file changed

+7
-1
lines changed

frontends/web/src/routes/account/utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,13 @@ export function getAccountsByKeystore(accounts: IAccount[]): TAccountsByKeystore
112112
}
113113
acc[key].accounts.push(account);
114114
return acc;
115-
}, {} as Record<string, TAccountsByKeystore>));
115+
}, {} as Record<string, TAccountsByKeystore>))
116+
// sort the output array as we noticed that somehow the input accounts
117+
// list seems to be possibly ordered differently in different places
118+
// in the code (e.g. sidebar vs manage account page)
119+
.sort((ac1, ac2) => {
120+
return ac1.keystore.name.localeCompare(ac2.keystore.name);
121+
});
116122
}
117123

118124
// Returns true if more than one keystore has the given name.

0 commit comments

Comments
 (0)