import lbry from '../lbry.js'; import React from 'react'; import {FormField} from '../component/form.js'; import Link from '../component/link'; const fs = require('fs'); const {ipcRenderer} = require('electron'); class DeveloperPage extends React.Component { constructor(props) { super(props); this.state = { showDeveloperMenu: lbry.getClientSetting('showDeveloperMenu'), useCustomLighthouseServers: lbry.getClientSetting('useCustomLighthouseServers'), customLighthouseServers: lbry.getClientSetting('customLighthouseServers').join('\n'), upgradePath: '', }; } handleShowDeveloperMenuChange(event) { lbry.setClientSetting('showDeveloperMenu', event.target.checked); lbry.showMenuIfNeeded(); this.setState({ showDeveloperMenu: event.target.checked, }); } handleUseCustomLighthouseServersChange(event) { lbry.setClientSetting('useCustomLighthouseServers', event.target.checked); this.setState({ useCustomLighthouseServers: event.target.checked, }); } handleUpgradeFileChange(event) { this.setState({ upgradePath: event.target.value, }); } handleForceUpgradeClick() { let upgradeSent = false; if (!this.state.upgradePath) { alert(__('Please select a file to upgrade from')); } else { try { const stats = fs.lstatSync(this.state.upgradePath); if (stats.isFile()) { console.log('Starting upgrade using ' + this.state.upgradePath); ipcRenderer.send('upgrade', this.state.upgradePath); upgradeSent = true; } } catch (e) {} if (!upgradeSent) { alert('Failed to start upgrade. Is "' + this.state.upgradePath + '" a valid path to the upgrade?'); } } } render() { return (

{__("Developer Settings")}

{this.state.useCustomLighthouseServers ?
: null}
{ this.handleUpgradeFileChange() }}/>   { this.handleForceUpgradeClick() }} />
); } } export default DeveloperPage;