import React from 'react'; import {FormField, FormRow} from 'component/form.js'; import SubHeader from 'component/subHeader' import lbry from 'lbry.js'; class SettingsPage extends React.Component { constructor(props) { super(props); const daemonSettings = this.props.daemonSettings this.state = { isMaxUpload: daemonSettings && daemonSettings.max_upload != 0, isMaxDownload: daemonSettings && daemonSettings.max_download != 0, showNsfw: lbry.getClientSetting('showNsfw'), showUnavailable: lbry.getClientSetting('showUnavailable'), } } setDaemonSetting(name, value) { this.props.setDaemonSetting(name, value) } setClientSetting(name, value) { lbry.setClientSetting(name, value) this._onSettingSaveSuccess() } onRunOnStartChange(event) { this.setDaemonSetting('run_on_startup', event.target.checked); } onShareDataChange(event) { this.setDaemonSetting('share_usage_data', event.target.checked); } onDownloadDirChange(event) { this.setDaemonSetting('download_directory', event.target.value); } onMaxUploadPrefChange(isLimited) { if (!isLimited) { this.setDaemonSetting('max_upload', 0.0); } this.setState({ isMaxUpload: isLimited }); } onMaxUploadFieldChange(event) { this.setDaemonSetting('max_upload', Number(event.target.value)); } onMaxDownloadPrefChange(isLimited) { if (!isLimited) { this.setDaemonSetting('max_download', 0.0); } this.setState({ isMaxDownload: isLimited }); } onMaxDownloadFieldChange(event) { this.setDaemonSetting('max_download', Number(event.target.value)); } onShowNsfwChange(event) { lbry.setClientSetting('showNsfw', event.target.checked); } onShowUnavailableChange(event) { } render() { const { daemonSettings } = this.props if (!daemonSettings) { return
Failed to load settings.
; } /*

Run on Startup

*/ return (

Download Directory

Bandwidth Limits

Max Upload
{ this.onMaxUploadPrefChange(false) }} defaultChecked={!this.state.isMaxUpload} label="Unlimited" />
{ this.onMaxUploadPrefChange(true) }} defaultChecked={this.state.isMaxUpload} label={ this.state.isMaxUpload ? 'Up to' : 'Choose limit...' } /> { this.state.isMaxUpload ? : '' } { this.state.isMaxUpload ? MB/s : '' }
Max Download
{ this.onMaxDownloadPrefChange(false) }} defaultChecked={!this.state.isMaxDownload} />
{ this.onMaxDownloadPrefChange(true) }} defaultChecked={this.state.isMaxDownload} label={ this.state.isMaxDownload ? 'Up to' : 'Choose limit...' } /> { this.state.isMaxDownload ? : '' } { this.state.isMaxDownload ? MB/s : '' }

Content

Share Diagnostic Data

); } } export default SettingsPage;