diff --git a/app/daemon.js b/app/daemon.js index 652cd04..57d774a 100644 --- a/app/daemon.js +++ b/app/daemon.js @@ -12,6 +12,7 @@ import { fileSync as tmpFileSync } from 'tmp' import request from 'request-promise-native' import { app, dialog } from 'electron' import pjson from '../package.json' +import Settings from 'electron-settings' /** * Execute an IPFS command asynchoniously, @@ -113,7 +114,18 @@ export function getAPIVersion () { */ export function startIPFSDaemon () { return new Promise((resolve, reject) => { - const ipfsProcess = spawnIPFSCommand('daemon', '--init', `--api=${global.IPFS_MULTIADDR_API}`) + const disablePubSubIPNS = Settings.getSync('disablePubSubIPNS') + + const args = [ + '--init', + `--api=${global.IPFS_MULTIADDR_API}` + ] + + if (!disablePubSubIPNS) { + args.push('--enable-namesys-pubsub') + } + + const ipfsProcess = spawnIPFSCommand('daemon', ...args) // Prepare temporary file for logging: const tmpLog = tmpFileSync({ keep: true }) diff --git a/app/windows/Settings/Components/ConnectivityPanel.jsx b/app/windows/Settings/Components/ConnectivityPanel.jsx index 5e2145b..1bfcdcc 100644 --- a/app/windows/Settings/Components/ConnectivityPanel.jsx +++ b/app/windows/Settings/Components/ConnectivityPanel.jsx @@ -19,7 +19,8 @@ class ConnectivityPanel extends React.Component { state = { gateway: GatewayEnum.SIDERUS, skipGatewayQuery: true, - runInBackground: true + runInBackground: true, + disablePubSubIPNS: false } componentWillMount () { @@ -29,14 +30,16 @@ class ConnectivityPanel extends React.Component { Promise.all([ Settings.get('gatewayURL'), Settings.get('skipGatewayQuery'), - Settings.get('runInBackground') + Settings.get('runInBackground'), + Settings.get('disablePubSubIPNS') ]) // .then(console.log) .then(values => this.setState({ gateway: values[0], skipGatewayQuery: values[1] || false, // the default (undefined) is considered true - runInBackground: typeof values[2] !== 'boolean' ? true : values[2] + runInBackground: typeof values[2] !== 'boolean' ? true : values[2], + disablePubSubIPNS: values[3] || false })) } @@ -82,6 +85,20 @@ class ConnectivityPanel extends React.Component { }) } + _handlePubSubIPNSChange = (event) => { + const nextValue = !this.state.disablePubSubIPNS + /** + * Save setting persistently + */ + Settings.setSync('disablePubSubIPNS', nextValue) + /** + * Update component's state + */ + this.setState({ + disablePubSubIPNS: nextValue + }) + } + render () { if (this.props.navigationStore.selected !== 0) return null if (!this.props.informationStore) return null @@ -131,6 +148,12 @@ class ConnectivityPanel extends React.Component { onChange={this._handleRunInBackgroundChange} /> } + + ) }