From 0260153e217f21c42531eebb55014097db81c33d Mon Sep 17 00:00:00 2001 From: Justin Maier Date: Fri, 16 Aug 2019 12:08:09 -0700 Subject: [PATCH] Sorting tweaks - remove sorting by multiaddr - fix location sorting - remove note sorting - simplify latency sorting --- src/bundles/peer-locations.js | 6 ++---- src/bundles/peers.js | 7 +------ src/peers/PeersTable/PeersTable.js | 8 ++++---- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/bundles/peer-locations.js b/src/bundles/peer-locations.js index 0c73ebdc0..73fc9888b 100644 --- a/src/bundles/peer-locations.js +++ b/src/bundles/peer-locations.js @@ -152,8 +152,7 @@ export default function (opts) { locationObj.latitude ] const connection = parseConnection(peer.addr) - const rawLatency = parseLatency(peer.latency) - const latency = rawLatency ? `${rawLatency}ms` : null + const latency = parseLatency(peer.latency) const notes = parseNotes(peer, bootstrapPeers) return { @@ -163,7 +162,6 @@ export default function (opts) { coordinates, connection, latency, - rawLatency, notes } }) @@ -251,7 +249,7 @@ const isNonHomeIPv4 = t => t[0] === 4 && t[1] !== '127.0.0.1' const toLocationString = loc => { if (!loc) return null const { country_name: country, city } = loc - return city && country ? `${city}, ${country}` : country + return city && country ? `${country}, ${city}` : country } const parseConnection = (multiaddr) => { diff --git a/src/bundles/peers.js b/src/bundles/peers.js index 0c466c92a..706a2c076 100644 --- a/src/bundles/peers.js +++ b/src/bundles/peers.js @@ -4,12 +4,7 @@ import ms from 'milliseconds' const bundle = createAsyncResourceBundle({ name: 'peers', actionBaseType: 'PEERS', - getPromise: ({ getIpfs }) => getIpfs().swarm.peers({ verbose: true }) - .then((peers) => peers.sort((a, b) => { - const aAddr = a.addr.toString() - const bAddr = b.addr.toString() - return aAddr.localeCompare(bAddr, undefined, { numeric: true, sensitivity: 'base' }) - })), + getPromise: ({ getIpfs }) => getIpfs().swarm.peers({ verbose: true }), staleAfter: ms.seconds(10), persist: false, checkIfOnline: false diff --git a/src/peers/PeersTable/PeersTable.js b/src/peers/PeersTable/PeersTable.js index d0e3807f5..722b9f0ad 100644 --- a/src/peers/PeersTable/PeersTable.js +++ b/src/peers/PeersTable/PeersTable.js @@ -49,7 +49,7 @@ export class PeersTable extends React.Component { const style = { width: '60px' } return cellData - ? {cellData} + ? {cellData}ms : - } @@ -83,7 +83,7 @@ export class PeersTable extends React.Component { const { className, peerLocationsForSwarm, t } = this.props const { sortBy, sortDirection } = this.state - const sortedList = (peerLocationsForSwarm || []).sort(sortByProperty(sortBy === 'latency' ? 'rawLatency' : sortBy, sortDirection === SortDirection.ASC ? 1 : -1)) + const sortedList = (peerLocationsForSwarm || []).sort(sortByProperty(sortBy, sortDirection === SortDirection.ASC ? 1 : -1)) const tableHeight = 400 return ( @@ -103,11 +103,11 @@ export class PeersTable extends React.Component { sort={this.sort} sortBy={sortBy} sortDirection={sortDirection}> - + - + )} }