Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Peer page sorting adjustments #1116

Merged
merged 1 commit into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/bundles/peer-locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -163,7 +162,6 @@ export default function (opts) {
coordinates,
connection,
latency,
rawLatency,
notes
}
})
Expand Down Expand Up @@ -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) => {
Expand Down
7 changes: 1 addition & 6 deletions src/bundles/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/peers/PeersTable/PeersTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class PeersTable extends React.Component {
const style = { width: '60px' }

return cellData
? <span className='dib tr' style={style}>{cellData}</span>
? <span className='dib tr' style={style}>{cellData}ms</span>
: <span className='dib tr o-40' style={style}>-</span>
}

Expand Down Expand Up @@ -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 (
Expand All @@ -103,11 +103,11 @@ export class PeersTable extends React.Component {
sort={this.sort}
sortBy={sortBy}
sortDirection={sortDirection}>
<Column label={t('location')} cellRenderer={this.locationCellRenderer} dataKey='locationCode' width={450} className='f6 navy-muted truncate pl2' />
<Column label={t('location')} cellRenderer={this.locationCellRenderer} dataKey='location' width={450} className='f6 navy-muted truncate pl2' />
<Column label={t('latency')} cellRenderer={this.latencyCellRenderer} dataKey='latency' width={250} className='f6 navy-muted monospace pl2' />
<Column label={t('peerId')} cellRenderer={this.peerIdCellRenderer} dataKey='peerId' width={250} className='charcoal monospace truncate f7 pl2' />
<Column label={t('connection')} dataKey='connection' width={400} className='f6 navy-muted truncate pl2' />
<Column label={t('notes')} cellRenderer={this.notesCellRenderer} dataKey='notes' width={400} className='charcoal monospace truncate f7 pl2' />
<Column label={t('notes')} cellRenderer={this.notesCellRenderer} disableSort dataKey='notes' width={400} className='charcoal monospace truncate f7 pl2' />
</Table>
)}
</AutoSizer> }
Expand Down