Minor cleanup

This commit is contained in:
Jobobby04 2022-07-24 15:29:48 -04:00
parent 87d7a47b8e
commit 7c2bbb7c00
3 changed files with 100 additions and 95 deletions

View File

@ -34,6 +34,11 @@ class GalleryAdder(
enabledLanguages().get() to disabledSources().get().map { it.toLong() }.toSet()
}
private val Pair<Set<String>, Set<Long>>.enabledLangs
get() = first
private val Pair<Set<String>, Set<Long>>.disabledSources
get() = second
private val logger = xLogStack()
fun pickSource(url: String): List<UrlImportableSource> {
@ -41,7 +46,7 @@ class GalleryAdder(
return sourceManager.getVisibleCatalogueSources()
.mapNotNull { it.getMainSource<UrlImportableSource>() }
.filter {
it.lang in filters.first && it.id !in filters.second && try {
it.lang in filters.enabledLangs && it.id !in filters.disabledSources && try {
it.matchesUri(uri)
} catch (e: Exception) {
false
@ -73,7 +78,7 @@ class GalleryAdder(
sourceManager.getVisibleCatalogueSources()
.mapNotNull { it.getMainSource<UrlImportableSource>() }
.find {
it.lang in filters.first && it.id !in filters.second && try {
it.lang in filters.enabledLangs && it.id !in filters.disabledSources && try {
it.matchesUri(uri)
} catch (e: Exception) {
false

View File

@ -42,6 +42,7 @@ import androidx.compose.ui.unit.dp
import eu.kanade.core.prefs.PreferenceMutableState
import eu.kanade.presentation.components.Divider
import eu.kanade.presentation.components.LazyColumn
import eu.kanade.presentation.components.LoadingScreen
import eu.kanade.presentation.components.PreferenceRow
import eu.kanade.presentation.components.SwitchPreference
import eu.kanade.tachiyomi.ui.base.controller.BasicComposeController
@ -80,7 +81,11 @@ class SettingsDebugController : BasicComposeController() {
DebugToggles.values().map { DebugToggle(it.name, it.asPref(viewScope), it.default) }
}
}
if (functions != null) {
if (functions == null) {
LoadingScreen()
return
}
val scope = rememberCoroutineScope()
Box(
Modifier
@ -167,14 +172,9 @@ class SettingsDebugController : BasicComposeController() {
ResultTextDialog(
result = result,
onDismissRequest = { result = null }
onDismissRequest = { result = null },
)
}
} else {
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
CircularProgressIndicator()
}
}
}
@Composable

View File

@ -3,11 +3,11 @@ package exh.ui.batchadd
import android.content.Context
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
import eu.kanade.tachiyomi.util.lang.withIOContext
import exh.GalleryAddEvent
import exh.GalleryAdder
import exh.log.xLogE
import exh.ui.base.CoroutinePresenter
import exh.util.trimOrNull
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.Dispatchers
@ -17,7 +17,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import uy.kohesive.injekt.injectLazy
class BatchAddPresenter : BasePresenter<BatchAddController>() {
class BatchAddPresenter : CoroutinePresenter<BatchAddController>() {
private val preferences: PreferencesHelper by injectLazy()
private val galleryAdder by lazy { GalleryAdder() }