diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhFilter.kt b/app/src/main/java/com/hippo/ehviewer/client/EhFilter.kt index 685834d20..cbbc9543b 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhFilter.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhFilter.kt @@ -16,6 +16,7 @@ package com.hippo.ehviewer.client import android.util.Log +import androidx.compose.runtime.mutableStateListOf import arrow.core.memoize import com.hippo.ehviewer.EhDB import com.hippo.ehviewer.client.data.GalleryInfo @@ -24,12 +25,12 @@ import com.hippo.ehviewer.dao.Filter private val regex = { p: Filter -> Regex(p.text!!) }.memoize() object EhFilter { - val titleFilterList = mutableListOf() - val uploaderFilterList = mutableListOf() - val tagFilterList = mutableListOf() - val tagNamespaceFilterList = mutableListOf() - val commenterFilterList = mutableListOf() - val commentFilterList = mutableListOf() + val titleFilterList = mutableStateListOf() + val uploaderFilterList = mutableStateListOf() + val tagFilterList = mutableStateListOf() + val tagNamespaceFilterList = mutableStateListOf() + val commenterFilterList = mutableStateListOf() + val commentFilterList = mutableStateListOf() const val MODE_TITLE = 0 const val MODE_UPLOADER = 1 diff --git a/app/src/main/java/com/hippo/ehviewer/ui/settings/FilterScreen.kt b/app/src/main/java/com/hippo/ehviewer/ui/settings/FilterScreen.kt index 0826f884b..6fda30c39 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/settings/FilterScreen.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/settings/FilterScreen.kt @@ -53,7 +53,6 @@ fun FilterScreen() { val context = LocalContext.current val coroutineScope = rememberCoroutineScope { Dispatchers.IO } val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() - val scaffoldRecomposeScope = currentRecomposeScope class AddFilterDialogHelper(private val dialog: AlertDialog) : View.OnClickListener { private val mArray = dialog.context.resources.getStringArray(R.array.filter_entries) private val binding = DialogAddFilterBinding.bind(dialog.findViewById(R.id.base)!!) @@ -88,7 +87,6 @@ fun FilterScreen() { error = null } } - scaffoldRecomposeScope.invalidate() dialog.dismiss() } } @@ -116,7 +114,6 @@ fun FilterScreen() { } }, ) { paddingValues -> - val lazyListRecomposeScope = currentRecomposeScope LazyColumn( modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), contentPadding = paddingValues, @@ -149,17 +146,7 @@ fun FilterScreen() { Text(text = filter.text.orEmpty()) Spacer(modifier = Modifier.weight(1F)) IconButton( - onClick = { - BaseDialogBuilder(context).setMessage(context.getString(R.string.delete_filter, filter.text)) - .setPositiveButton(R.string.delete) { _, which -> - if (DialogInterface.BUTTON_POSITIVE == which) { - coroutineScope.launch { - EhFilter.deleteFilter(filter) - lazyListRecomposeScope.invalidate() - } - } - }.setNegativeButton(android.R.string.cancel, null).show() - }, + onClick = { BaseDialogBuilder(context).setMessage(context.getString(R.string.delete_filter, filter.text)).setPositiveButton(R.string.delete) { _, which -> if (DialogInterface.BUTTON_POSITIVE == which) { coroutineScope.launch { EhFilter.deleteFilter(filter) } } }.setNegativeButton(android.R.string.cancel, null).show() }, ) { Icon(imageVector = Icons.Default.Delete, contentDescription = null) }