mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-23 21:12:34 +01:00
Optimize source settings flow
This commit is contained in:
@@ -15,6 +15,7 @@ import kotlinx.coroutines.Job
|
|||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.asStateFlow
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
import kotlinx.coroutines.flow.drop
|
import kotlinx.coroutines.flow.drop
|
||||||
|
import kotlinx.coroutines.flow.filterNotNull
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -40,11 +41,9 @@ class SourceSettingsViewModel @Inject constructor(
|
|||||||
subscriptions.forEach { it.cancel() }
|
subscriptions.forEach { it.cancel() }
|
||||||
subscriptions.clear()
|
subscriptions.clear()
|
||||||
subscriptions += settings.map { setting ->
|
subscriptions += settings.map { setting ->
|
||||||
setting.state.drop(1).onEach {
|
setting.state.drop(1).filterNotNull().onEach {
|
||||||
if (it != null) {
|
sourceHandler.setSourceSetting(params.sourceId, setting.index, it)
|
||||||
sourceHandler.setSourceSetting(params.sourceId, setting.index, it)
|
getSourceSettings()
|
||||||
getSourceSettings()
|
|
||||||
}
|
|
||||||
}.launchIn(scope)
|
}.launchIn(scope)
|
||||||
}
|
}
|
||||||
}.launchIn(scope)
|
}.launchIn(scope)
|
||||||
|
|||||||
Reference in New Issue
Block a user