Only check for custom nodes locally once

This commit is contained in:
Daniel Ternyak 2018-07-06 17:46:26 -05:00
parent 06c8ae6e5b
commit 895b959822
No known key found for this signature in database
GPG Key ID: DF212D2DC5D0E245

View File

@ -71,7 +71,7 @@ class CustomNodeModal extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.pollForDefaultNodes();
this.checkForDefaultNodes();
}
public componentDidUpdate(prevProps: Props) {
@ -251,27 +251,22 @@ class CustomNodeModal extends React.Component<Props, State> {
);
}
private pollForDefaultNodes() {
const pollingInterval = 3000;
this.timer = window.setInterval(async () => {
const results = await exists(
[
// tslint:disable-next-line:no-http-string
{ type: 'http', addr: 'http://localhost', port: 8545, timeout: 3000 }
],
{ includeDefaults: false }
);
if (!this.timer) {
return;
}
this.setState({
defaultNodes: results.filter(r => r.success).map((r, index) => ({
...r,
display: `${r.addr}:${r.port}`,
index
}))
});
}, pollingInterval);
private async checkForDefaultNodes() {
const results = await exists(
[
// tslint:disable-next-line:no-http-string
{ type: 'http', addr: 'http://localhost', port: 8545, timeout: 3000 }
],
{ includeDefaults: false }
);
this.setState({
defaultNodes: results.filter(r => r.success).map((r, index) => ({
...r,
display: `${r.addr}:${r.port}`,
index
}))
});
}
private renderDefaultNodeDropdown() {