import React from 'react'; import FormField from 'component/formField'; import { FormRow } from 'component/form.js'; import SubHeader from 'component/subHeader'; import * as settings from 'constants/settings'; import lbry from 'lbry.js'; import Link from 'component/link'; import FormFieldPrice from 'component/formFieldPrice'; class SettingsPage extends React.PureComponent { constructor(props) { super(props); this.state = { clearingCache: false, }; this.onAutomaticDarkModeChange = this.onAutomaticDarkModeChange.bind(this); } clearCache() { this.setState({ clearingCache: true, }); const success = () => { this.setState({ clearingCache: false }); window.location.href = 'index.html'; }; const clear = () => this.props.clearCache().then(success.bind(this)); setTimeout(clear, 1000, { once: true }); } setDaemonSetting(name, value) { this.props.setDaemonSetting(name, value); } 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); } onKeyFeeChange(newValue) { const setting = newValue; // this is stupid and should be fixed... somewhere if (setting && (setting.amount === undefined || setting.amount === null)) { setting.amount = 0; } this.setDaemonSetting('max_key_fee', setting); } onKeyFeeDisableChange(isDisabled) { this.setDaemonSetting('disable_max_key_fee', isDisabled); } onThemeChange(event) { const { value } = event.target; if (value === 'dark') { this.onAutomaticDarkModeChange(false); } this.props.setClientSetting(settings.THEME, value); } onAutomaticDarkModeChange(value) { this.props.setClientSetting(settings.AUTOMATIC_DARK_MODE_ENABLED, value); } onInstantPurchaseEnabledChange(enabled) { this.props.setClientSetting(settings.INSTANT_PURCHASE_ENABLED, enabled); } onInstantPurchaseMaxChange(newValue) { this.props.setClientSetting(settings.INSTANT_PURCHASE_MAX, newValue); } // 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) { this.props.setClientSetting(settings.SHOW_NSFW, event.target.checked); } onLanguageChange(e) { this.props.changeLanguage(e.target.value); this.forceUpdate(); } onShowUnavailableChange(event) { this.props.setClientSetting(settings.SHOW_UNAVAILABLE, event.target.checked); } componentWillMount() { this.props.getThemes(); } componentDidMount() {} render() { const { daemonSettings, language, languages, showNsfw, instantPurchaseEnabled, instantPurchaseMax, showUnavailable, theme, themes, automaticDarkModeEnabled, } = this.props; if (!daemonSettings || Object.keys(daemonSettings).length === 0) { return (
{__('Failed to load settings.')}
); } return (
{/*

{__("Language")}

{Object.keys(languages).map(dLang => )}
*/}

{__('Download Directory')}

{__('Max Purchase Price')}

{ this.onKeyFeeDisableChange(true); }} defaultChecked={daemonSettings.disable_max_key_fee} label={__('No Limit')} />
{ this.onKeyFeeDisableChange(false); }} defaultChecked={!daemonSettings.disable_max_key_fee} label={daemonSettings.disable_max_key_fee ? __('Choose limit') : __('Limit to')} /> {!daemonSettings.disable_max_key_fee && ( )}
{__( 'This will prevent you from purchasing any content over this cost, as a safety measure.' )}

{__('Purchase Confirmations')}

{ this.onInstantPurchaseEnabledChange(false); }} />
{ this.onInstantPurchaseEnabledChange(true); }} /> {instantPurchaseEnabled && ( this.onInstantPurchaseMaxChange(val)} defaultValue={instantPurchaseMax} /> )}
When this option is chosen, LBRY won't ask you to confirm downloads below the given price.

{__('Content')}

{__('Share Diagnostic Data')}

{__('Theme')}

{themes.map((theme, index) => ( ))} this.onAutomaticDarkModeChange(e.target.checked)} checked={automaticDarkModeEnabled} label={__('Automatic dark mode (9pm to 8am)')} />

{__('Application Cache')}

); } } export default SettingsPage;