From 62fd918587fb16eb14737efee18f74f57d57837f Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Thu, 7 Feb 2019 01:51:16 -0500 Subject: [PATCH] maint: key fee settings + bump SDK Disable setting is no longer part of SDK settings so I moved it into local storage. Also moved in the max fee setting since it's now cleared out from the SDK. --- package.json | 2 +- src/renderer/constants/settings.js | 2 ++ src/renderer/page/settings/index.js | 2 ++ src/renderer/page/settings/view.jsx | 26 ++++++++++++++----------- src/renderer/redux/actions/settings.js | 2 +- src/renderer/redux/reducers/settings.js | 5 +++++ 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 10912e2cc..8cf408b46 100644 --- a/package.json +++ b/package.json @@ -135,7 +135,7 @@ "yarn": "^1.3" }, "lbrySettings": { - "lbrynetDaemonVersion": "0.31.0rc5", + "lbrynetDaemonVersion": "0.31.0", "lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-OSNAME.zip", "lbrynetDaemonDir": "static/daemon", "lbrynetDaemonFileName": "lbrynet" diff --git a/src/renderer/constants/settings.js b/src/renderer/constants/settings.js index a00c97a9b..2e9c49a9f 100644 --- a/src/renderer/constants/settings.js +++ b/src/renderer/constants/settings.js @@ -17,3 +17,5 @@ export const AUTOPLAY = 'autoplay'; export const RESULT_COUNT = 'resultCount'; export const OS_NOTIFICATIONS_ENABLED = 'osNotificationsEnabled'; export const AUTO_DOWNLOAD = 'autoDownload'; +export const DISABLE_MAX_KEY_FEE = 'disableMaxKeyFee'; +export const LOCAL_MAX_KEY_FEE = 'localMaxKeyFee'; diff --git a/src/renderer/page/settings/index.js b/src/renderer/page/settings/index.js index 6d178b368..46ee4e029 100644 --- a/src/renderer/page/settings/index.js +++ b/src/renderer/page/settings/index.js @@ -31,6 +31,8 @@ const select = state => ({ walletEncrypted: selectWalletIsEncrypted(state), osNotificationsEnabled: selectosNotificationsEnabled(state), autoDownload: makeSelectClientSetting(settings.AUTO_DOWNLOAD)(state), + disableMaxKeyFee: makeSelectClientSetting(settings.DISABLE_MAX_KEY_FEE)(state), + localMaxKeyFee: makeSelectClientSetting(settings.LOCAL_MAX_KEY_FEE)(state), }); const perform = dispatch => ({ diff --git a/src/renderer/page/settings/view.jsx b/src/renderer/page/settings/view.jsx index af72f882f..6037653fc 100644 --- a/src/renderer/page/settings/view.jsx +++ b/src/renderer/page/settings/view.jsx @@ -14,7 +14,6 @@ export type Price = { type DaemonSettings = { download_dir: string, - disable_max_key_fee: boolean, share_usage_data: boolean, max_key_fee?: Price, }; @@ -38,6 +37,8 @@ type Props = { updateWalletStatus: () => void, walletEncrypted: boolean, osNotificationsEnabled: boolean, + disableMaxKeyFee: boolean, + localMaxKeyFee: Price, }; type State = { @@ -54,6 +55,7 @@ class SettingsPage extends React.PureComponent { (this: any).onDownloadDirChange = this.onDownloadDirChange.bind(this); (this: any).onKeyFeeChange = this.onKeyFeeChange.bind(this); + (this: any).onKeyFeeDisableChange = this.onKeyFeeDisableChange.bind(this); (this: any).onInstantPurchaseMaxChange = this.onInstantPurchaseMaxChange.bind(this); (this: any).onShowNsfwChange = this.onShowNsfwChange.bind(this); (this: any).onShareDataChange = this.onShareDataChange.bind(this); @@ -84,11 +86,14 @@ class SettingsPage extends React.PureComponent { } onKeyFeeChange(newValue: Price) { + this.props.setClientSetting(SETTINGS.LOCAL_MAX_KEY_FEE, newValue); this.setDaemonSetting('max_key_fee', newValue); } onKeyFeeDisableChange(isDisabled: boolean) { - this.setDaemonSetting('disable_max_key_fee', isDisabled); + this.props.setClientSetting(SETTINGS.DISABLE_MAX_KEY_FEE, isDisabled); + // null is default value passed to clear key fee + if (isDisabled) this.setDaemonSetting('max_key_fee', ''); } onThemeChange(event: SyntheticInputEvent<*>) { @@ -138,7 +143,7 @@ class SettingsPage extends React.PureComponent { this.props.setClientSetting(SETTINGS.OS_NOTIFICATIONS_ENABLED, event.target.checked); } - setDaemonSetting(name: string, value: boolean | string | Price) { + setDaemonSetting(name: string, value: boolean | string | Price | ''): void { this.props.setDaemonSetting(name, value); } @@ -168,6 +173,8 @@ class SettingsPage extends React.PureComponent { walletEncrypted, osNotificationsEnabled, autoDownload, + disableMaxKeyFee, + localMaxKeyFee, } = this.props; const noDaemonSettings = !daemonSettings || Object.keys(daemonSettings).length === 0; @@ -210,7 +217,7 @@ class SettingsPage extends React.PureComponent { { this.onKeyFeeDisableChange(true); @@ -219,23 +226,20 @@ class SettingsPage extends React.PureComponent { { this.onKeyFeeDisableChange(false); + this.onKeyFeeChange(localMaxKeyFee); }} - checked={!daemonSettings.disable_max_key_fee} postfix={__('Choose limit')} /> - {!daemonSettings.disable_max_key_fee && ( + {!disableMaxKeyFee && ( )} diff --git a/src/renderer/redux/actions/settings.js b/src/renderer/redux/actions/settings.js index 5ce87f9bc..ab3d9e907 100644 --- a/src/renderer/redux/actions/settings.js +++ b/src/renderer/redux/actions/settings.js @@ -24,7 +24,7 @@ export function doSetDaemonSetting(key, value) { return dispatch => { const newSettings = { key, - value, + value: value || null, }; Lbry.settings_set(newSettings).then(newSettings); Lbry.settings_get().then(settings => { diff --git a/src/renderer/redux/reducers/settings.js b/src/renderer/redux/reducers/settings.js index e61542429..49ded0603 100644 --- a/src/renderer/redux/reducers/settings.js +++ b/src/renderer/redux/reducers/settings.js @@ -10,6 +10,11 @@ function getLocalStorageSetting(setting, fallback) { const reducers = {}; const defaultState = { clientSettings: { + [SETTINGS.DISABLE_MAX_KEY_FEE]: getLocalStorageSetting(SETTINGS.DISABLE_MAX_KEY_FEE, false), + [SETTINGS.LOCAL_MAX_KEY_FEE]: getLocalStorageSetting(SETTINGS.LOCAL_MAX_KEY_FEE, { + currency: 'USD', + amount: 50.0, + }), [SETTINGS.INSTANT_PURCHASE_ENABLED]: getLocalStorageSetting( SETTINGS.INSTANT_PURCHASE_ENABLED, false