Add polling warning for console snoopers

This commit is contained in:
Daniel Ternyak 2018-07-06 18:27:46 -05:00
parent 895b959822
commit 3497bffffe
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.checkForDefaultNodes();
this.pollForDefaultNodes();
}
public componentDidUpdate(prevProps: Props) {
@ -251,7 +251,13 @@ class CustomNodeModal extends React.Component<Props, State> {
);
}
private async checkForDefaultNodes() {
private pollForDefaultNodes() {
const pollingInterval = 3000;
// console.warning in production to explain to users why we are making a call to localhost
console.warn(
"Don't panic! MyCrypto is going to start a poll for default nodes on port 8545. If you don't like this feature, send us a ping at support@mycrypto.com and we'll walk you through disabling it."
);
this.timer = window.setInterval(async () => {
const results = await exists(
[
// tslint:disable-next-line:no-http-string
@ -259,7 +265,9 @@ class CustomNodeModal extends React.Component<Props, State> {
],
{ includeDefaults: false }
);
if (!this.timer) {
return;
}
this.setState({
defaultNodes: results.filter(r => r.success).map((r, index) => ({
...r,
@ -267,6 +275,7 @@ class CustomNodeModal extends React.Component<Props, State> {
index
}))
});
}, pollingInterval);
}
private renderDefaultNodeDropdown() {