Skip to content

Commit

Permalink
updates app/components/NodeSelectPanel/NodeSelectPanel.jsx and reduce…
Browse files Browse the repository at this point in the history
…s ping override in nodeNetworkActions.js to 5000 ms
  • Loading branch information
comountainclimber committed Jan 11, 2019
1 parent bf3c1fd commit 71acd74
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 66 deletions.
8 changes: 2 additions & 6 deletions app/actions/nodeNetworkActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {
} from '../core/constants'

const ID = 'nodeNetwork'
const MAX_RESPONSE_TIME = 10000
const RPC_PING_OVERRIDE = 10000
const RPC_PING_OVERRIDE = 5000

const pingNodes = (nodes: Array<any>) => {
settings.timeout.ping = RPC_PING_OVERRIDE
Expand All @@ -38,12 +37,9 @@ const pingNodes = (nodes: Array<any>) => {
}
})
.catch(console.error)

// if condition on line 58 is never met return the results
// that were obtained instead of waiting indefinitely
setTimeout(() => {
resolve(responses)
}, MAX_RESPONSE_TIME)
}, RPC_PING_OVERRIDE)
})
})
}
Expand Down
95 changes: 35 additions & 60 deletions app/components/NodeSelectPanel/NodeSelectPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,66 +151,10 @@ export default class NodeSelect extends React.Component<Props, State> {
loadNodesData,
networkId,
} = this.props
if (!nodes.length) {
return loading ? (
<Loading theme={theme} nobackground />
) : (
<DialogueBox
icon={<WarningIcon className={styles.warningIcon} />}
renderText={() => (
<div>
Oops! There was an issue retrieving metrics from the network.{" "}
<a onClick={() => loadNodesData({ networkId })}>Retry?</a>
</div>
)}
className={styles.tokenSalePanelDialogueBox}
/>
);
}

return ... (other condition)
return <Loading theme={theme} nobackground />
}
if (nodes.length) {
const listItems = nodes.map((node, index) => {
const { latency, blockCount, url } = node

let icon
let rowClass
if (selectedNode === url) {
icon = <ConfirmIcon className={styles.icon} />
rowClass = styles.selected
} else {
icon = <AddIcon className={styles.icon} />
}

return (
<div
key={index}
className={classNames(styles.row, rowClass, {
[styles.odd]: index % 2 !== 0,
})}
>
<div className={styles.latency}>
<div className={this.getLatencyClass(parseInt(latency, 10))} />
<span>{latency}ms</span>
</div>
<div className={styles.blockHeight}>Block Height: {blockCount}</div>
<div className={styles.url}>{url}</div>
<div
className={styles.select}
onClick={() => this.handleSelect(url)}
>
{icon}
<span>Select</span>
</div>
</div>
)
})
return <div className={styles.content}>{listItems}</div>
}
if (!loading && !nodes.length) {
return (
if (!nodes.length) {
return loading ? (
<Loading theme={theme} nobackground />
) : (
<DialogueBox
icon={<WarningIcon className={styles.warningIcon} />}
renderText={() => (
Expand All @@ -223,6 +167,37 @@ return ... (other condition)
/>
)
}
const listItems = nodes.map((node, index) => {
const { latency, blockCount, url } = node
let icon
let rowClass
if (selectedNode === url) {
icon = <ConfirmIcon className={styles.icon} />
rowClass = styles.selected
} else {
icon = <AddIcon className={styles.icon} />
}
return (
<div
key={index}
className={classNames(styles.row, rowClass, {
[styles.odd]: index % 2 !== 0,
})}
>
<div className={styles.latency}>
<div className={this.getLatencyClass(parseInt(latency, 10))} />
<span>{latency}ms</span>
</div>
<div className={styles.blockHeight}>Block Height: {blockCount}</div>
<div className={styles.url}>{url}</div>
<div className={styles.select} onClick={() => this.handleSelect(url)}>
{icon}
<span>Select</span>
</div>
</div>
)
})
return <div className={styles.content}>{listItems}</div>
}

renderIcon = () => (
Expand Down

0 comments on commit 71acd74

Please sign in to comment.