Testing fixes 0.53.4 (#7600)

* view hosting setting backspace, and storage setting scroll to button

* fix duplicate settings_get call

* avoid unneccessary setDaemonSetting unlimited
This commit is contained in:
jessopb 2022-06-03 16:09:34 -04:00 committed by GitHub
parent 168ae17eb6
commit 7b0d38eca7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 12 deletions

View file

@ -14,7 +14,7 @@ const select = (state) => ({
const perform = (dispatch) => ({ const perform = (dispatch) => ({
getDaemonStatus: () => dispatch(doGetDaemonStatus()), getDaemonStatus: () => dispatch(doGetDaemonStatus()),
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)), setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
cleanBlobs: () => dispatch(doCleanBlobs()), cleanBlobs: () => dispatch(doCleanBlobs(false)),
}); });
export default connect(select, perform)(SettingWalletServer); export default connect(select, perform)(SettingWalletServer);

View file

@ -45,7 +45,7 @@ export default function SettingStorage(props: Props) {
</h2> </h2>
</div> </div>
<Card <Card
id={SETTINGS_GRP.SYSTEM} id={SETTINGS_GRP.STORAGE}
isBodyList isBodyList
body={ body={
<> <>

View file

@ -14,7 +14,7 @@ const select = (state) => ({
const perform = (dispatch) => ({ const perform = (dispatch) => ({
getDaemonStatus: () => dispatch(doGetDaemonStatus()), getDaemonStatus: () => dispatch(doGetDaemonStatus()),
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)), setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
cleanBlobs: () => dispatch(doCleanBlobs()), cleanBlobs: () => dispatch(doCleanBlobs(false)),
}); });
export default connect(select, perform)(SettingViewHosting); export default connect(select, perform)(SettingViewHosting);

View file

@ -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() { async function handleApply() {
if (unlimited) { if (unlimited) {
await setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, '0'); await setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, '0');
@ -91,10 +101,11 @@ function SettingViewHosting(props: Props) {
} }
React.useEffect(() => { React.useEffect(() => {
if (unlimited) { // basically handle setUnlimited
if (unlimited && viewHostingLimit !== 0) {
handleApply(); handleApply();
} }
}, [unlimited]); }, [unlimited, viewHostingLimit]);
return ( return (
<> <>
@ -119,6 +130,9 @@ function SettingViewHosting(props: Props) {
// disabled if settings are equal or not valid amounts // disabled if settings are equal or not valid amounts
(viewHostingLimit === 1 && contentBlobSpaceLimitGB <= MINIMUM_VIEW_SETTING) || (viewHostingLimit === 1 && contentBlobSpaceLimitGB <= MINIMUM_VIEW_SETTING) ||
(unlimited && viewHostingLimit === 0) || (unlimited && viewHostingLimit === 0) ||
(!unlimited &&
(String(viewHostingLimit) === convertGbToMbStr(contentBlobSpaceLimitGB) ||
!isValidHostingAmount(String(contentBlobSpaceLimitGB)))) ||
(!unlimited && (!unlimited &&
String(viewHostingLimit) === String(viewHostingLimit) ===
convertGbToMbStr( convertGbToMbStr(
@ -139,8 +153,10 @@ function SettingViewHosting(props: Props) {
(viewHostingLimit === 1 && contentBlobSpaceLimitGB <= MINIMUM_VIEW_SETTING) || (viewHostingLimit === 1 && contentBlobSpaceLimitGB <= MINIMUM_VIEW_SETTING) ||
(unlimited && viewHostingLimit === 0) || (unlimited && viewHostingLimit === 0) ||
(!unlimited && (!unlimited &&
(String(viewHostingLimit) === convertGbToMbStr(contentBlobSpaceLimitGB) || String(viewHostingLimit) ===
!isValidHostingAmount(String(contentBlobSpaceLimitGB)))) || convertGbToMbStr(
contentBlobSpaceLimitGB || !isValidHostingAmount(String(contentBlobSpaceLimitGB))
)) ||
isSetting || isSetting ||
disabled disabled
} }
@ -156,7 +172,7 @@ function SettingViewHosting(props: Props) {
onWheel={(e) => e.preventDefault()} onWheel={(e) => e.preventDefault()}
label={__(`View Hosting Limit (GB)`)} label={__(`View Hosting Limit (GB)`)}
onChange={(e) => handleContentLimitChange(e.target.value)} onChange={(e) => handleContentLimitChange(e.target.value)}
value={Number(contentBlobSpaceLimitGB) <= Number(MINIMUM_VIEW_SETTING) ? '0' : contentBlobSpaceLimitGB} value={getContentLimitValue()}
/> />
</div> </div>
</> </>

View file

@ -7,9 +7,7 @@ import React from 'react';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import classnames from 'classnames'; import classnames from 'classnames';
import Button from 'component/button'; import Button from 'component/button';
// @if TARGET='app'
import { IS_MAC } from 'component/app/view'; import { IS_MAC } from 'component/app/view';
// @endif
import { useIsMediumScreen } from 'effects/use-screensize'; import { useIsMediumScreen } from 'effects/use-screensize';
type SideNavLink = { type SideNavLink = {

View file

@ -154,10 +154,12 @@ export function doSetDaemonSetting(key, value, doNotDispatch = false) {
}; };
} }
export function doCleanBlobs() { export function doCleanBlobs(fetchAfter = true) {
return (dispatch) => { return (dispatch) => {
return Lbry.blob_clean().then(() => { return Lbry.blob_clean().then(() => {
dispatch(doFetchDaemonSettings()); if (fetchAfter) {
dispatch(doFetchDaemonSettings());
}
return 'done'; return 'done';
}); });
}; };