Drop unused coroutineScope

This commit is contained in:
tarsin committed 2023-07-01 12:21:46 +08:00
1 parent 227cbd6fba
commit a7b239f0b9
2 files changed
+6 -9

No files matched your search

@@ -27,18 +27,18 @@ import kotlinx.coroutines.launch
private val regex = { p: Filter -> Regex(p.text) }.memoize()
private inline fun List<Filter>.anyActive(predicate: (Filter) -> Boolean) = any { it.enable && predicate(it) }
object EhFilter {
object EhFilter : CoroutineScope {
val titleFilterList = mutableStateListOf<Filter>()
val uploaderFilterList = mutableStateListOf<Filter>()
val tagFilterList = mutableStateListOf<Filter>()
val tagNamespaceFilterList = mutableStateListOf<Filter>()
val commenterFilterList = mutableStateListOf<Filter>()
val commentFilterList = mutableStateListOf<Filter>()
private val opScope = CoroutineScope(Dispatchers.IO.limitedParallelism(1))
private fun <R> Filter.launchOps(callback: ((R) -> Unit)? = null, ops: Filter.() -> R) = opScope.launch {
val r = ops()
callback?.invoke(r)
}
override val coroutineContext = Dispatchers.IO.limitedParallelism(1)
private fun <R> Filter.launchOps(
callback: ((R) -> Unit)? = null,
ops: Filter.() -> R,
) = launch { ops().let { callback?.invoke(it) } }
fun Filter.remember(callback: ((Boolean) -> Unit)? = null) = launchOps(callback) {
EhDB.addFilter(this).also { if (it) memorizeFilter(this) }
}
@@ -31,7 +31,6 @@ import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.currentRecomposeScope
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
@@ -47,13 +46,11 @@ import com.hippo.ehviewer.dao.Filter
import com.hippo.ehviewer.databinding.DialogAddFilterBinding
import com.hippo.ehviewer.ui.LocalNavController
import com.hippo.ehviewer.ui.legacy.BaseDialogBuilder
import kotlinx.coroutines.Dispatchers
@Composable
fun FilterScreen() {
val navController = LocalNavController.current
val context = LocalContext.current
val coroutineScope = rememberCoroutineScope { Dispatchers.IO }
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
class AddFilterDialogHelper(private val dialog: AlertDialog) : View.OnClickListener {
private val mArray = dialog.context.resources.getStringArray(R.array.filter_entries)