var React = require('react') var Icon = require('icon.jsx') module.exports = function (boardsAPI) { return React.createClass({ getDefaults: function () { return { addr: 'localhost', port: 5001, api: false } }, getInitialState: function () { boardsAPI.use(boards => { if (boards.isInit && this.isMounted()) this.setState({ api: true }) boards.getEventEmitter().on('init', (err, limited) => { if ((!err || limited) && this.isMounted()) { this.setState({ api: true, limited }) } }) }) var s = window.localStorage.getItem('ipfs-boards-settings') var obj = this.getDefaults() try { obj = JSON.parse(s) } catch (e) { window.localStorage.removeItem('ipfs-boards-settings') } return obj || this.getDefaults() }, save: function () { if (isNaN(this.state.port) || parseInt(this.state.port, 10) > 65535 || parseInt(this.state.port, 10) < 1) { window.alert('Port number invalid') } else { window.localStorage.setItem('ipfs-boards-settings', JSON.stringify({ addr: this.state.addr, port: parseInt(this.state.port, 10) })) window.location.reload(false) } }, setDefaults: function () { this.setState(this.getDefaults()) }, onChange: function (event) { if (event.target.id === 'nodeAddress') { this.setState({ addr: event.target.value }) } else { this.setState({ port: event.target.value }) } }, isOK: function () { if (this.state.limited) { return
Some features may not be available.
You're connected to IPFS
In the future, this won't be necessary because IPFS will run in your browser.
All settings are saved in your browser's localStorage.