// @flow import { ALERT } from 'constants/icons'; import { SETTINGS_GRP } from 'constants/settings'; import React from 'react'; import Button from 'component/button'; import Card from 'component/common/card'; import { FormField } from 'component/common/form'; import FileSelector from 'component/common/file-selector'; import I18nMessage from 'component/i18nMessage'; import SettingAutoLaunch from 'component/settingAutoLaunch'; import SettingClosingBehavior from 'component/settingClosingBehavior'; import SettingCommentsServer from 'component/settingCommentsServer'; import SettingDataHosting from 'component/settingDataHosting'; import SettingShareUrl from 'component/settingShareUrl'; import SettingsRow from 'component/settingsRow'; import SettingWalletServer from 'component/settingWalletServer'; import Spinner from 'component/spinner'; import { getPasswordFromCookie } from 'util/saved-passwords'; import * as DAEMON_SETTINGS from 'constants/daemon_settings'; import SettingEnablePrereleases from 'component/settingEnablePrereleases'; const IS_MAC = process.platform === 'darwin'; type Price = { currency: string, amount: number, }; type SetDaemonSettingArg = boolean | string | number | Price; type DaemonSettings = { download_dir: string, share_usage_data: boolean, max_key_fee?: Price, max_connections_per_download?: number, save_files: boolean, save_blobs: boolean, ffmpeg_path: string, }; type Props = { // --- select --- daemonSettings: DaemonSettings, ffmpegStatus: { available: boolean, which: string }, findingFFmpeg: boolean, walletEncrypted: boolean, isAuthenticated: boolean, allowAnalytics: boolean, // --- perform --- setDaemonSetting: (string, ?SetDaemonSettingArg) => void, clearDaemonSetting: (string) => void, clearCache: () => Promise, findFFmpeg: () => void, encryptWallet: () => void, decryptWallet: () => void, updateWalletStatus: () => void, confirmForgetPassword: ({}) => void, toggle3PAnalytics: (boolean) => void, }; export default function SettingSystem(props: Props) { const { daemonSettings, ffmpegStatus, findingFFmpeg, walletEncrypted, isAuthenticated, allowAnalytics, setDaemonSetting, clearDaemonSetting, clearCache, findFFmpeg, encryptWallet, decryptWallet, updateWalletStatus, confirmForgetPassword, toggle3PAnalytics, } = props; const [clearingCache, setClearingCache] = React.useState(false); const [storedPassword, setStoredPassword] = React.useState(false); const { available: ffmpegAvailable, which: ffmpegPath } = ffmpegStatus; function onChangeEncryptWallet() { if (walletEncrypted) { decryptWallet(); } else { encryptWallet(); } } function onConfirmForgetPassword() { confirmForgetPassword({ callback: () => setStoredPassword(false) }); } // Update ffmpeg variables React.useEffect(() => { const { available } = ffmpegStatus; const { ffmpeg_path: ffmpegPath } = daemonSettings; if (!available) { if (ffmpegPath) { clearDaemonSetting('ffmpeg_path'); } findFFmpeg(); } }, []); // eslint-disable-line react-hooks/exhaustive-deps // Update storedPassword state React.useEffect(() => { updateWalletStatus(); getPasswordFromCookie().then((p) => { if (typeof p === 'string') { setStoredPassword(true); } }); }, []); // eslint-disable-line react-hooks/exhaustive-deps return ( <>

{__('System')}

{/* @if TARGET='app' */} { setDaemonSetting('download_dir', newDirectory.path); }} /> {/* @endif */} setDaemonSetting('save_files', !daemonSettings.save_files)} checked={daemonSettings.save_files} /> {__('Help improve the P2P data network (and make LBRY happy) by hosting data.')}{' '} {__("View History Hosting lets you choose how much storage to use helping content you've consumed.")}{' '} {/* {__( */} {/* 'Automatic Hosting lets you delegate some amount of storage for the network to automatically download and host.' */} {/* )}{' '} */} {__('Playing videos may exceed your history hosting limit until cleanup runs every 30 minutes.')}