Use SharedFlow for available extensions to always emit the value (#7609)
- Fixes Extension screen being stuck refreshing due to StateFlow not emitting due to the value being the same (cherry picked from commit 73901f50c0aee1cb82695642af72ff6ac7bc232d)
This commit is contained in:
parent
7c2bbb7c00
commit
7edf8dd555
@ -25,8 +25,11 @@ import exh.source.EH_SOURCE_ID
|
|||||||
import exh.source.EXH_SOURCE_ID
|
import exh.source.EXH_SOURCE_ID
|
||||||
import exh.source.MERGED_SOURCE_ID
|
import exh.source.MERGED_SOURCE_ID
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import kotlinx.coroutines.flow.asSharedFlow
|
||||||
import kotlinx.coroutines.flow.asStateFlow
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
@ -107,15 +110,15 @@ class ExtensionManager(
|
|||||||
var availableExtensions = emptyList<Extension.Available>()
|
var availableExtensions = emptyList<Extension.Available>()
|
||||||
private set(value) {
|
private set(value) {
|
||||||
field = value
|
field = value
|
||||||
availableExtensionsFlow.value = field
|
availableExtensionsFlow.tryEmit(field)
|
||||||
updatedInstalledExtensionsStatuses(value)
|
updatedInstalledExtensionsStatuses(value)
|
||||||
setupAvailableExtensionsSourcesDataMap(value)
|
setupAvailableExtensionsSourcesDataMap(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val availableExtensionsFlow = MutableStateFlow(availableExtensions)
|
private val availableExtensionsFlow = MutableSharedFlow<List<Extension.Available>>(replay = 1)
|
||||||
|
|
||||||
fun getAvailableExtensionsFlow(): StateFlow<List<Extension.Available>> {
|
fun getAvailableExtensionsFlow(): Flow<List<Extension.Available>> {
|
||||||
return availableExtensionsFlow.asStateFlow()
|
return availableExtensionsFlow.asSharedFlow()
|
||||||
}
|
}
|
||||||
|
|
||||||
private var availableExtensionsSourcesData: Map<Long, SourceData> = mapOf()
|
private var availableExtensionsSourcesData: Map<Long, SourceData> = mapOf()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user