Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroncox committed Jan 15, 2018
1 parent 2a22440 commit 3b99798
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions app/components/global/ServerSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import React, { Component } from 'react';

import { Button, Header, Modal, Segment, Table } from 'semantic-ui-react';
import { Asset, Price, Client } from 'dsteem'
import { Client } from 'dsteem';

const servers = [
'wss://gtg.steem.house:8090',
'wss://seed.bitcoiner.me',
Expand All @@ -12,7 +13,7 @@ const servers = [
'wss://steemd.privex.io',
'wss://steemd.steemitstage.com',
'wss://steemd.steemgigs.org',
]
];

export default class ServerSelect extends Component {

Expand All @@ -23,9 +24,9 @@ export default class ServerSelect extends Component {
}

startStatus = () => {
this.setState({open: true})
this.setState({open: true});
this.interval = setInterval(this.checkStatus.bind(this), 15000);
this.checkStatus()
this.checkStatus();
}

componentWillUnmount() {
Expand All @@ -34,28 +35,29 @@ export default class ServerSelect extends Component {

stopStatus = () => {
clearInterval(this.interval);
this.setState({ loading: false, open: false })
this.setState({ loading: false, open: false });
}

selectServer = (e, data) => {
const server = data.value;
const { refreshGlobalProps, setPreference } = this.props.actions;
clearInterval(this.interval);
this.setState({ loading: true, open: false })
this.setState({ loading: true, open: false });
setPreference('steemd_node', server);
refreshGlobalProps()
refreshGlobalProps();
}

checkStatus = () => {
servers.forEach((server) => {
try {
const client = new Client(server);
const config = client.database.getDynamicGlobalProperties().then((props) => {
client.database.getDynamicGlobalProperties().then((props) => {
let servers = Object.assign({}, this.state.servers);
servers[server.replace('wss', 'https')] = props.time;
this.setState({servers});
});
} catch(e) {
console.log(e)
}
})
}
Expand All @@ -78,26 +80,26 @@ export default class ServerSelect extends Component {
</Button>
</Table.Cell>
</Table.Row>
)
})
);
});
return (
<Modal
closeIcon={true}
color='blue'
size='large'
color="blue"
size="large"
loading={this.state.loading}
onOpen={this.startStatus}
onClose={this.stopStatus}
open={this.state.open}
trigger={
<Button floated='right' color='red' content='Change Servers'/>
<Button floated="right" color="red" content="Change Servers"/>
}
>
<Header attached='top'>
<Header attached="top">
Select a Steem server to connect to:
</Header>
<Segment loading={this.state.loading}>
<Table attached='bottom'>
<Table attached="bottom">
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Expand All @@ -107,7 +109,7 @@ export default class ServerSelect extends Component {
Last Block
</Table.HeaderCell>
<Table.HeaderCell>

Controls
</Table.HeaderCell>
</Table.Row>
</Table.Header>
Expand Down

0 comments on commit 3b99798

Please sign in to comment.