2021-08-05 10:41:45 +02:00
// @flow
import { ALERT } from 'constants/icons' ;
import React from 'react' ;
import Button from 'component/button' ;
import Card from 'component/common/card' ;
2021-08-06 10:25:37 +02:00
import { FormField } from 'component/common/form' ;
2021-08-05 10:41:45 +02:00
import SettingAutoLaunch from 'component/settingAutoLaunch' ;
import SettingClosingBehavior from 'component/settingClosingBehavior' ;
2021-08-07 15:12:07 +02:00
import SettingCommentsServer from 'component/settingCommentsServer' ;
2021-08-05 10:41:45 +02:00
import SettingsRow from 'component/settingsRow' ;
2021-08-07 15:12:07 +02:00
import SettingWalletServer from 'component/settingWalletServer' ;
2021-08-05 10:41:45 +02:00
// @if TARGET='app'
const IS _MAC = process . platform === 'darwin' ;
// @endif
2021-08-06 10:25:37 +02:00
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 ,
} ;
2021-08-05 10:41:45 +02:00
type Props = {
2021-08-06 10:25:37 +02:00
daemonSettings : DaemonSettings ,
setDaemonSetting : ( string , ? SetDaemonSettingArg ) => void ,
2021-08-05 10:41:45 +02:00
clearCache : ( ) => Promise < any > ,
} ;
export default function SettingSystem ( props : Props ) {
2021-08-06 10:25:37 +02:00
const { daemonSettings , setDaemonSetting , clearCache } = props ;
2021-08-05 10:41:45 +02:00
const [ clearingCache , setClearingCache ] = React . useState ( false ) ;
return (
< Card
title = { _ _ ( 'System' ) }
subtitle = ""
isBodyList
body = {
< >
2021-08-06 10:25:37 +02:00
{ /* @if TARGET='app' */ }
< SettingsRow
title = { _ _ ( 'Save all viewed content to your downloads directory' ) }
subtitle = { _ _ (
'Paid content and some file types are saved by default. Changing this setting will not affect previously downloaded content.'
) }
>
< FormField
type = "checkbox"
name = "save_files"
onChange = { ( ) => setDaemonSetting ( 'save_files' , ! daemonSettings . save _files ) }
checked = { daemonSettings . save _files }
/ >
< / SettingsRow >
< SettingsRow
title = { _ _ ( 'Save hosting data to help the LBRY network' ) }
subtitle = {
< React.Fragment >
{ _ _ ( "If disabled, LBRY will be very sad and you won't be helping improve the network." ) } { ' ' }
< Button button = "link" label = { _ _ ( 'Learn more' ) } href = "https://lbry.com/faq/host-content" / > .
< / React.Fragment >
}
>
< FormField
type = "checkbox"
name = "save_blobs"
onChange = { ( ) => setDaemonSetting ( 'save_blobs' , ! daemonSettings . save _blobs ) }
checked = { daemonSettings . save _blobs }
/ >
< / SettingsRow >
{ /* @endif */ }
2021-08-05 10:41:45 +02:00
{ /* @if TARGET='app' */ }
{ /* Auto launch in a hidden state doesn't work on mac https://github.com/Teamwork/node-auto-launch/issues/81 */ }
{ ! IS _MAC && (
2021-08-06 10:25:37 +02:00
< SettingsRow
title = { _ _ ( 'Start minimized' ) }
subtitle = { _ _ (
'Improve view speed and help the LBRY network by allowing the app to cuddle up in your system tray.'
) }
>
2021-08-05 10:41:45 +02:00
< SettingAutoLaunch noLabels / >
< / SettingsRow >
) }
{ /* @endif */ }
{ /* @if TARGET='app' */ }
< SettingsRow title = { _ _ ( 'Leave app running in notification area when the window is closed' ) } >
< SettingClosingBehavior noLabels / >
< / SettingsRow >
{ /* @endif */ }
2021-08-07 15:12:07 +02:00
{ /* @if TARGET='app' */ }
< SettingsRow title = { _ _ ( 'Experimental settings' ) } useVerticalSeparator >
{ /* Disabling below until we get downloads to work with shared subscriptions code */ }
{ / *
< FormField
type = "checkbox"
name = "auto_download"
onChange = { ( ) => setClientSetting ( SETTINGS . AUTO _DOWNLOAD , ! autoDownload ) }
checked = { autoDownload }
label = { _ _ ( 'Automatically download new content from my subscriptions' ) }
helper = { _ _ (
"The latest file from each of your subscriptions will be downloaded for quick access as soon as it's published."
) }
/ >
* / }
< fieldset - section >
< FormField
name = "max_connections"
type = "select"
label = { _ _ ( 'Max Connections' ) }
helper = { _ _ (
'For users with good bandwidth, try a higher value to improve streaming and download speeds. Low bandwidth users may benefit from a lower setting. Default is 4.'
) }
min = { 1 }
max = { 100 }
onChange = { ( e ) => setDaemonSetting ( 'max_connections_per_download' , e . target . value ) }
value = { daemonSettings . max _connections _per _download }
>
{ [ 1 , 2 , 4 , 6 , 10 , 20 ] . map ( ( connectionOption ) => (
< option key = { connectionOption } value = { connectionOption } >
{ connectionOption }
< / option >
) ) }
< / FormField >
< / f i e l d s e t - s e c t i o n >
< SettingWalletServer / >
< SettingCommentsServer / >
< / SettingsRow >
{ /* @endif */ }
2021-08-06 10:25:37 +02:00
< SettingsRow
title = { _ _ ( 'Clear application cache' ) }
subtitle = { _ _ ( 'This might fix issues that you are having. Your wallet will not be affected.' ) }
>
2021-08-05 10:41:45 +02:00
< Button
button = "secondary"
icon = { ALERT }
label = { clearingCache ? _ _ ( 'Clearing' ) : _ _ ( 'Clear Cache' ) }
onClick = { ( ) => {
setClearingCache ( true ) ;
clearCache ( ) ;
} }
disabled = { clearingCache }
/ >
< / SettingsRow >
< / >
}
/ >
) ;
}