[System] grab Network & Data Settings

This commit is contained in:
infinite-persistence 2021-08-06 16:25:37 +08:00
parent 52472f3cfb
commit 502ab6f6a9
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
4 changed files with 70 additions and 47 deletions

View file

@ -1,10 +1,15 @@
import { connect } from 'react-redux';
import { doClearCache } from 'redux/actions/app';
import { doSetDaemonSetting } from 'redux/actions/settings';
import { selectDaemonSettings } from 'redux/selectors/settings';
import SettingSystem from './view';
const select = (state) => ({});
const select = (state) => ({
daemonSettings: selectDaemonSettings(state),
});
const perform = (dispatch) => ({
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
clearCache: () => dispatch(doClearCache()),
});

View file

@ -3,6 +3,7 @@ import { ALERT } from 'constants/icons';
import React from 'react';
import Button from 'component/button';
import Card from 'component/common/card';
import { FormField } from 'component/common/form';
import SettingAutoLaunch from 'component/settingAutoLaunch';
import SettingClosingBehavior from 'component/settingClosingBehavior';
import SettingsRow from 'component/settingsRow';
@ -11,12 +12,31 @@ import SettingsRow from 'component/settingsRow';
const IS_MAC = process.platform === 'darwin';
// @endif
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 = {
daemonSettings: DaemonSettings,
setDaemonSetting: (string, ?SetDaemonSettingArg) => void,
clearCache: () => Promise<any>,
};
export default function SettingSystem(props: Props) {
const { clearCache } = props;
const { daemonSettings, setDaemonSetting, clearCache } = props;
const [clearingCache, setClearingCache] = React.useState(false);
return (
@ -26,10 +46,47 @@ export default function SettingSystem(props: Props) {
isBodyList
body={
<>
{/* @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 */}
{/* @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 && (
<SettingsRow title={__('Start minimized')} subtitle={__(HELP_START_MINIMIZED)}>
<SettingsRow
title={__('Start minimized')}
subtitle={__(
'Improve view speed and help the LBRY network by allowing the app to cuddle up in your system tray.'
)}
>
<SettingAutoLaunch noLabels />
</SettingsRow>
)}
@ -41,7 +98,10 @@ export default function SettingSystem(props: Props) {
</SettingsRow>
{/* @endif */}
<SettingsRow title={__('Clear application cache')} subtitle={__(HELP_CLEAR_CACHE)}>
<SettingsRow
title={__('Clear application cache')}
subtitle={__('This might fix issues that you are having. Your wallet will not be affected.')}
>
<Button
button="secondary"
icon={ALERT}
@ -58,7 +118,3 @@ export default function SettingSystem(props: Props) {
/>
);
}
const HELP_START_MINIMIZED =
'Improve view speed and help the LBRY network by allowing the app to cuddle up in your system tray.';
const HELP_CLEAR_CACHE = 'This might fix issues that you are having. Your wallet will not be affected.';

View file

@ -2,7 +2,6 @@ import { connect } from 'react-redux';
import { doClearCache, doNotifyEncryptWallet, doNotifyDecryptWallet, doNotifyForgetPassword } from 'redux/actions/app';
import { selectAllowAnalytics } from 'redux/selectors/app';
import {
doSetDaemonSetting,
doClearDaemonSetting,
doSetClientSetting,
doFindFFmpeg,
@ -33,7 +32,6 @@ const select = (state) => ({
});
const perform = (dispatch) => ({
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
clearDaemonSetting: (key) => dispatch(doClearDaemonSetting(key)),
clearCache: () => dispatch(doClearCache()),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),

View file

@ -32,7 +32,6 @@ type DaemonSettings = {
};
type Props = {
setDaemonSetting: (string, ?SetDaemonSettingArg) => void,
clearDaemonSetting: (string) => void,
setClientSetting: (string, SetDaemonSettingArg) => void,
daemonSettings: DaemonSettings,
@ -155,7 +154,7 @@ class SettingsAdvancedPage extends React.PureComponent<Props, State> {
}
setDaemonSetting(name: string, value: ?SetDaemonSettingArg): void {
this.props.setDaemonSetting(name, value);
// this.props.setDaemonSetting(name, value);
}
clearDaemonSetting(name: string): void {
@ -174,7 +173,6 @@ class SettingsAdvancedPage extends React.PureComponent<Props, State> {
instantPurchaseMax,
isAuthenticated,
walletEncrypted,
setDaemonSetting,
setClientSetting,
hideBalance,
findingFFmpeg,
@ -203,40 +201,6 @@ class SettingsAdvancedPage extends React.PureComponent<Props, State> {
</section>
) : (
<div>
{/* @if TARGET='app' */}
<Card
title={__('Network and data settings')}
actions={
<React.Fragment>
<FormField
type="checkbox"
name="save_files"
onChange={() => setDaemonSetting('save_files', !daemonSettings.save_files)}
checked={daemonSettings.save_files}
label={__('Save all viewed content to your downloads directory')}
helper={__(
'Paid content and some file types are saved by default. Changing this setting will not affect previously downloaded content.'
)}
/>
<FormField
type="checkbox"
name="save_blobs"
onChange={() => setDaemonSetting('save_blobs', !daemonSettings.save_blobs)}
checked={daemonSettings.save_blobs}
label={__('Save hosting data to help the LBRY network')}
helper={
<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>
}
/>
</React.Fragment>
}
/>
{/* @endif */}
<Card
title={__('Purchase and tip confirmations')}
actions={