mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-13 12:38:58 +01:00
Cleanup Preference.asHotFlow() (#9257)
* Drop duplicate initial call in Preference.asHotFlow Preference.changes() always starts by returning the current value of the preference, so asHotFlow calls block twice on the initial value. Possible breaking change: As implemented, asHotFlow ran block(get()) before returning the flow. After this change, the first call to block will run within the flow collection. This might cause concurrency issues if the flow collection is late to execute. * Inline Preference.asHotFlow The Preference.changes().onEach().launchIn() pattern is used widely, so the asHotFlow extension method is redundant.
This commit is contained in:
@@ -7,13 +7,13 @@ import androidx.core.view.inputmethod.EditorInfoCompat
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import eu.kanade.domain.base.BasePreferences
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
||||
import eu.kanade.tachiyomi.widget.TachiyomiTextInputEditText.Companion.setIncognito
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
@@ -49,8 +49,8 @@ class TachiyomiTextInputEditText @JvmOverloads constructor(
|
||||
* if [BasePreferences.incognitoMode] is true. Some IMEs may not respect this flag.
|
||||
*/
|
||||
fun EditText.setIncognito(viewScope: CoroutineScope) {
|
||||
Injekt.get<BasePreferences>().incognitoMode()
|
||||
.asHotFlow {
|
||||
Injekt.get<BasePreferences>().incognitoMode().changes()
|
||||
.onEach {
|
||||
imeOptions = if (it) {
|
||||
imeOptions or EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user