From df1ac382da7da05aaa53313d82d4cfc8e6ccf577 Mon Sep 17 00:00:00 2001
From: YouROK <8yourok8@mail.ru>
Date: Sun, 11 Jul 2021 17:13:57 +0300
Subject: [PATCH] add preload cache, need remove PreloadBuffer
---
.../Settings/PrimarySettingsComponent.jsx | 15 ++++++++++++---
web/src/components/Settings/SettingsDialog.jsx | 12 +++++++++---
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/web/src/components/Settings/PrimarySettingsComponent.jsx b/web/src/components/Settings/PrimarySettingsComponent.jsx
index 643e6bf..89a0b63 100644
--- a/web/src/components/Settings/PrimarySettingsComponent.jsx
+++ b/web/src/components/Settings/PrimarySettingsComponent.jsx
@@ -32,10 +32,12 @@ export default function PrimarySettingsComponent({
settings,
inputForm,
cachePercentage,
+ preloadCachePercentage,
cacheSize,
isProMode,
setCacheSize,
setCachePercentage,
+ setPreloadCachePercentage,
updateSettings,
}) {
const { t } = useTranslation()
@@ -94,10 +96,17 @@ export default function PrimarySettingsComponent({
inputMax={100}
/>
- }
- label={t('SettingsDialog.PreloadBuffer')}
+
+
{UseDisk ? (
diff --git a/web/src/components/Settings/SettingsDialog.jsx b/web/src/components/Settings/SettingsDialog.jsx
index 5c3368a..b93662a 100644
--- a/web/src/components/Settings/SettingsDialog.jsx
+++ b/web/src/components/Settings/SettingsDialog.jsx
@@ -27,6 +27,7 @@ export default function SettingsDialog({ handleClose }) {
const [selectedTab, setSelectedTab] = useState(0)
const [cacheSize, setCacheSize] = useState(32)
const [cachePercentage, setCachePercentage] = useState(40)
+ const [preloadCachePercentage, setPreloadCachePercentage] = useState(0)
const [isProMode, setIsProMode] = useState(JSON.parse(localStorage.getItem('isProMode')) || false)
useEffect(() => {
@@ -40,6 +41,7 @@ export default function SettingsDialog({ handleClose }) {
const sets = JSON.parse(JSON.stringify(settings))
sets.CacheSize = cacheSize * 1024 * 1024
sets.ReaderReadAHead = cachePercentage
+ sets.PreloadCache = preloadCachePercentage
axios.post(settingsHost(), { action: 'set', sets })
}
@@ -65,14 +67,15 @@ export default function SettingsDialog({ handleClose }) {
setSettings(sets)
}
- const { CacheSize, ReaderReadAHead } = settings || {}
+ const { CacheSize, ReaderReadAHead, PreloadCache } = settings || {}
useEffect(() => {
- if (!CacheSize || !ReaderReadAHead) return
+ if (!CacheSize || !ReaderReadAHead || !PreloadCache) return
setCacheSize(CacheSize)
setCachePercentage(ReaderReadAHead)
- }, [CacheSize, ReaderReadAHead])
+ setPreloadCachePercentage(PreloadCache)
+ }, [CacheSize, ReaderReadAHead, PreloadCache])
const updateSettings = newProps => setSettings({ ...settings, ...newProps })
const handleChange = (_, newValue) => setSelectedTab(newValue)
@@ -134,10 +137,12 @@ export default function SettingsDialog({ handleClose }) {
settings={settings}
inputForm={inputForm}
cachePercentage={cachePercentage}
+ preloadCachePercentage={preloadCachePercentage}
cacheSize={cacheSize}
isProMode={isProMode}
setCacheSize={setCacheSize}
setCachePercentage={setCachePercentage}
+ setPreloadCachePercentage={setPreloadCachePercentage}
updateSettings={updateSettings}
/>
@@ -161,6 +166,7 @@ export default function SettingsDialog({ handleClose }) {
onClick={() => {
setCacheSize(defaultSettings.CacheSize)
setCachePercentage(defaultSettings.ReaderReadAHead)
+ setPreloadCachePercentage(defaultSettings.PreloadCache)
updateSettings(defaultSettings)
}}
color='secondary'