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..."
This commit is contained in:
Sean Darcy 2022-08-15 11:52:25 +10:00
parent 019b8d3a9b
commit c44a3666f3
1 changed files with 14 additions and 7 deletions

View File

@ -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
}),