Allow configure thumb concurrency temporarily

This commit is contained in:
Dude so hot authored and renovate[bot] committed 2024-10-21 20:54:37 +08:00
1 parent cf6f793478
commit 1af7aa8a16
3 files changed
+11 -2

No files matched your search

@@ -212,6 +212,7 @@ object Settings : DataStorePreferences(null) {
val showNavigationOverlayNewUser = boolPref("reader_navigation_overlay_new_user", true)
val showNavigationOverlayOnStart = boolPref("reader_navigation_overlay_on_start", false)
val stripExtraneousAds = boolPref("strip_extraneous_ads", false)
var thumbConcurrency by intPref("thumb_concurrency", 4)
val userAgent
get() = if (desktopSite) CHROME_USER_AGENT else CHROME_MOBILE_USER_AGENT
@@ -4,6 +4,7 @@ import coil3.network.NetworkClient
import coil3.network.NetworkRequest
import coil3.network.NetworkResponse
import coil3.network.ktor3.asNetworkClient
import com.hippo.ehviewer.Settings
import com.hippo.ehviewer.client.URL_PREFIX_THUMB_E
import com.hippo.ehviewer.client.URL_PREFIX_THUMB_EX
import io.ktor.client.HttpClient
@@ -11,8 +12,8 @@ import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.sync.withPermit
class LimitConcurrencyNetworkClient(val impl: NetworkClient) : NetworkClient {
val eSemaphore = Semaphore(4)
val exSemaphore = Semaphore(4)
val eSemaphore = Semaphore(Settings.thumbConcurrency)
val exSemaphore = Semaphore(Settings.thumbConcurrency)
override suspend fun <T> executeRequest(req: NetworkRequest, f: suspend (NetworkResponse) -> T): T {
val url = req.url
return when {
@@ -182,6 +182,13 @@ fun AdvancedScreen(navigator: DestinationsNavigator) {
value = Settings::enableCronet,
)
}
IntSliderPreference(
maxValue = 16,
minValue = 2,
step = 1,
title = "Thumb Concurrency (Restart required)",
value = Settings::thumbConcurrency,
)
if (isAtLeastO) {
IntSliderPreference(
maxValue = 16384,