diff --git a/lotuspond/front/src/Address.js b/lotuspond/front/src/Address.js index f3c7df73d..3b98b0f6f 100644 --- a/lotuspond/front/src/Address.js +++ b/lotuspond/front/src/Address.js @@ -27,11 +27,15 @@ class Address extends React.Component { componentDidMount() { this.refresh() if(!this.props.ts) { - let updates = setInterval(this.refresh, 2050) - this.props.client.on('close', () => clearInterval(updates)) + this.updates = setInterval(this.refresh, 2050) + this.props.client.on('close', () => clearInterval(this.updates)) } } + componentWillUnmount() { + clearInterval(this.updates) + } + async refresh() { let balance = 0 let actor = {} diff --git a/lotuspond/front/src/NodeList.js b/lotuspond/front/src/NodeList.js index 5db07bfa5..5da9f05dc 100644 --- a/lotuspond/front/src/NodeList.js +++ b/lotuspond/front/src/NodeList.js @@ -65,6 +65,7 @@ class NodeList extends React.Component { pondClient={this.props.client} fullConn={this.state.nodes[fullId].conn} mountWindow={this.props.mountWindow} + stop={this.stopNode(node.ID, onClose)} />) } }) diff --git a/lotuspond/front/src/StorageNode.js b/lotuspond/front/src/StorageNode.js index e2f2f86de..65d8388f0 100644 --- a/lotuspond/front/src/StorageNode.js +++ b/lotuspond/front/src/StorageNode.js @@ -29,6 +29,7 @@ class StorageNode extends React.Component { this.loadInfo = this.loadInfo.bind(this) this.sealGarbage = this.sealGarbage.bind(this) + this.stop = this.stop.bind(this) this.connect() } @@ -59,7 +60,8 @@ class StorageNode extends React.Component { // this.props.onConnect(client, id) // TODO: dedupe connecting part this.loadInfo() - setInterval(this.loadInfo, 1050) + let updates = setInterval(this.loadInfo, 1050) + client.on('close', () => clearInterval(updates)) }) console.log(token) // todo: use @@ -89,6 +91,10 @@ class StorageNode extends React.Component { await this.state.client.call("Filecoin.StoreGarbageData", []) } + async stop() { + await this.props.stop() + } + render() { let runtime =
if (this.state.actor) { @@ -117,7 +123,8 @@ class StorageNode extends React.Component { return + initialPosition={{x: this.props.node.ID*30, y: this.props.node.ID * 30}} + onClose={this.stop} >
{runtime}