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) => ({
getDaemonStatus: () => dispatch(doGetDaemonStatus()),
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
cleanBlobs: () => dispatch(doCleanBlobs()),
cleanBlobs: () => dispatch(doCleanBlobs(false)),
});
export default connect(select, perform)(SettingWalletServer);

View file

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

View file

@ -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);

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() {
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()}
/>
</div>
</>

View file

@ -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 = {

View file

@ -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';
});
};