import React from "react"; import { FormField, FormRow } from "component/form.js"; import SubHeader from "component/subHeader"; import lbry from "lbry.js"; import Link from "component/link"; const { remote } = require("electron"); class SettingsPage extends React.PureComponent { constructor(props) { super(props); const { daemonSettings } = this.props; this.state = { // isMaxUpload: daemonSettings && daemonSettings.max_upload != 0, // isMaxDownload: daemonSettings && daemonSettings.max_download != 0, showUnavailable: lbry.getClientSetting("showUnavailable"), language: lbry.getClientSetting("language"), clearingCache: false, }; } clearCache() { this.setState({ clearingCache: true, }); const success = () => { this.setState({ clearingCache: false }); window.location.href = `${remote.app.getAppPath()}/dist/index.html`; }; const clear = () => this.props.clearCache().then(success.bind(this)); setTimeout(clear, 1000, { once: true }); } 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); } onKeyFeeChange(event) { var oldSettings = this.props.daemonSettings.max_key_fee; var newSettings = { amount: oldSettings.amount, currency: oldSettings.currency, }; newSettings.amount = Number(event.target.value); this.setDaemonSetting("max_key_fee", newSettings); } onFeeCurrencyChange(event) { var oldSettings = this.props.daemonSettings.max_key_fee; var newSettings = { amount: oldSettings.amount, currency: oldSettings.currency, }; newSettings.currency = event.target.value; this.setDaemonSetting("max_key_fee", newSettings); } onKeyFeeDisableChange(isDisabled) { this.setDaemonSetting("disable_max_key_fee", isDisabled); } // 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("showNsfw", event.target.checked); } // onLanguageChange(language) { // lbry.setClientSetting('language', language); // i18n.setLocale(language); // this.setState({language: language}) // } onShowUnavailableChange(event) {} render() { const { daemonSettings } = this.props; if (!daemonSettings) { return (
{__("Failed to load settings.")}
); } /*

Run on Startup

*/ /*

{__("Language")}

{ this.onLanguageChange("en"); }} defaultChecked={this.state.language == "en"} />
{ this.onLanguageChange("rs"); }} defaultChecked={this.state.language == "rs"} />
*/ /*

{__("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 : ""}
*/ return (

{__("Download Directory")}

{__("Max Purchase Price")}

{__("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 ? : ""} {!daemonSettings.disable_max_key_fee ? : ""}
{__( "This will prevent you from purchasing any content over this cost, as a safety measure." )}

{__("Content")}

{__("Share Diagnostic Data")}

{__("Application Cache")}

); } } export default SettingsPage;