diff --git a/ui/component/settingDataHosting/index.js b/ui/component/settingDataHosting/index.js index d3c67819f..26c905128 100644 --- a/ui/component/settingDataHosting/index.js +++ b/ui/component/settingDataHosting/index.js @@ -14,7 +14,7 @@ const select = (state) => ({ const perform = (dispatch) => ({ getDaemonStatus: () => dispatch(doGetDaemonStatus()), setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)), - cleanBlobs: () => dispatch(doCleanBlobs()), + cleanBlobs: () => dispatch(doCleanBlobs(false)), }); export default connect(select, perform)(SettingWalletServer); diff --git a/ui/component/settingStorage/view.jsx b/ui/component/settingStorage/view.jsx index cdc06f442..1de4002a0 100644 --- a/ui/component/settingStorage/view.jsx +++ b/ui/component/settingStorage/view.jsx @@ -45,7 +45,7 @@ export default function SettingStorage(props: Props) { diff --git a/ui/component/settingViewHosting/index.js b/ui/component/settingViewHosting/index.js index 3ab46ebfa..7e9930725 100644 --- a/ui/component/settingViewHosting/index.js +++ b/ui/component/settingViewHosting/index.js @@ -14,7 +14,7 @@ const select = (state) => ({ const perform = (dispatch) => ({ getDaemonStatus: () => dispatch(doGetDaemonStatus()), setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)), - cleanBlobs: () => dispatch(doCleanBlobs()), + cleanBlobs: () => dispatch(doCleanBlobs(false)), }); export default connect(select, perform)(SettingViewHosting); diff --git a/ui/component/settingViewHosting/view.jsx b/ui/component/settingViewHosting/view.jsx index a4b881187..ff0a13050 100644 --- a/ui/component/settingViewHosting/view.jsx +++ b/ui/component/settingViewHosting/view.jsx @@ -67,6 +67,16 @@ function SettingViewHosting(props: Props) { } } + function getContentLimitValue() { + if (contentBlobSpaceLimitGB === '') { + return ''; + } else if (Number(contentBlobSpaceLimitGB) <= Number(MINIMUM_VIEW_SETTING)) { + return '0'; + } else { + return contentBlobSpaceLimitGB; + } + } + async function handleApply() { if (unlimited) { await setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, '0'); @@ -91,10 +101,11 @@ function SettingViewHosting(props: Props) { } React.useEffect(() => { - if (unlimited) { + // basically handle setUnlimited + if (unlimited && viewHostingLimit !== 0) { handleApply(); } - }, [unlimited]); + }, [unlimited, viewHostingLimit]); return ( <> @@ -119,6 +130,9 @@ function SettingViewHosting(props: Props) { // disabled if settings are equal or not valid amounts (viewHostingLimit === 1 && contentBlobSpaceLimitGB <= MINIMUM_VIEW_SETTING) || (unlimited && viewHostingLimit === 0) || + (!unlimited && + (String(viewHostingLimit) === convertGbToMbStr(contentBlobSpaceLimitGB) || + !isValidHostingAmount(String(contentBlobSpaceLimitGB)))) || (!unlimited && String(viewHostingLimit) === convertGbToMbStr( @@ -139,8 +153,10 @@ function SettingViewHosting(props: Props) { (viewHostingLimit === 1 && contentBlobSpaceLimitGB <= MINIMUM_VIEW_SETTING) || (unlimited && viewHostingLimit === 0) || (!unlimited && - (String(viewHostingLimit) === convertGbToMbStr(contentBlobSpaceLimitGB) || - !isValidHostingAmount(String(contentBlobSpaceLimitGB)))) || + String(viewHostingLimit) === + convertGbToMbStr( + contentBlobSpaceLimitGB || !isValidHostingAmount(String(contentBlobSpaceLimitGB)) + )) || isSetting || disabled } @@ -156,7 +172,7 @@ function SettingViewHosting(props: Props) { onWheel={(e) => e.preventDefault()} label={__(`View Hosting Limit (GB)`)} onChange={(e) => handleContentLimitChange(e.target.value)} - value={Number(contentBlobSpaceLimitGB) <= Number(MINIMUM_VIEW_SETTING) ? '0' : contentBlobSpaceLimitGB} + value={getContentLimitValue()} /> diff --git a/ui/component/settingsSideNavigation/view.jsx b/ui/component/settingsSideNavigation/view.jsx index b3972bd93..d3d52a20c 100644 --- a/ui/component/settingsSideNavigation/view.jsx +++ b/ui/component/settingsSideNavigation/view.jsx @@ -7,9 +7,7 @@ import React from 'react'; import { useHistory } from 'react-router-dom'; import classnames from 'classnames'; import Button from 'component/button'; -// @if TARGET='app' import { IS_MAC } from 'component/app/view'; -// @endif import { useIsMediumScreen } from 'effects/use-screensize'; type SideNavLink = { diff --git a/ui/redux/actions/settings.js b/ui/redux/actions/settings.js index aaf8b75dc..63509740f 100644 --- a/ui/redux/actions/settings.js +++ b/ui/redux/actions/settings.js @@ -154,10 +154,12 @@ export function doSetDaemonSetting(key, value, doNotDispatch = false) { }; } -export function doCleanBlobs() { +export function doCleanBlobs(fetchAfter = true) { return (dispatch) => { return Lbry.blob_clean().then(() => { - dispatch(doFetchDaemonSettings()); + if (fetchAfter) { + dispatch(doFetchDaemonSettings()); + } return 'done'; }); };