From c44a3666f37a72605c99611956cc74f7dd15ee69 Mon Sep 17 00:00:00 2001 From: Sean Darcy Date: Mon, 15 Aug 2022 11:52:25 +1000 Subject: [PATCH] Sorts the "MY STAKES" service node list alphabetically The list provided to users under service nodes -> my stakes previously had no sorting, which made it slightly difficult to find the service node as they would appear in a random order. This simply applys an alphabetical ordering over the service node pubkeys so that service node pubkey "0fa72..." will appear before pubkey "7eee3..." --- .../service_node/service_node_unlock.vue | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/service_node/service_node_unlock.vue b/src/components/service_node/service_node_unlock.vue index 13beccf..930d283 100644 --- a/src/components/service_node/service_node_unlock.vue +++ b/src/components/service_node/service_node_unlock.vue @@ -72,13 +72,20 @@ export default { node.contributors.find( c => c.address === this.our_address && c.amount > 0 ); - return nodes.filter(getOurContribution).map(n => { - const ourContribution = getOurContribution(n); - return { - ...n, - ourContributionAmount: ourContribution.amount - }; - }); + return nodes + .filter(getOurContribution) + .sort((a, b) => { + if (a.service_node_pubkey < b.service_node_pubkey) return -1; + if (a.service_node_pubkey > b.service_node_pubkey) return 1; + return 0; + }) + .map(n => { + const ourContribution = getOurContribution(n); + return { + ...n, + ourContributionAmount: ourContribution.amount + }; + }); }, fetching: state => state.gateway.daemon.service_nodes.fetching }),