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:
Andreas 2022-07-25 14:31:41 +02:00 committed by Jobobby04
parent 7c2bbb7c00
commit 7edf8dd555

View File

@ -25,8 +25,11 @@ import exh.source.EH_SOURCE_ID
import exh.source.EXH_SOURCE_ID
import exh.source.MERGED_SOURCE_ID
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import logcat.LogPriority
import rx.Observable
@ -107,15 +110,15 @@ class ExtensionManager(
var availableExtensions = emptyList<Extension.Available>()
private set(value) {
field = value
availableExtensionsFlow.value = field
availableExtensionsFlow.tryEmit(field)
updatedInstalledExtensionsStatuses(value)
setupAvailableExtensionsSourcesDataMap(value)
}
private val availableExtensionsFlow = MutableStateFlow(availableExtensions)
private val availableExtensionsFlow = MutableSharedFlow<List<Extension.Available>>(replay = 1)
fun getAvailableExtensionsFlow(): StateFlow<List<Extension.Available>> {
return availableExtensionsFlow.asStateFlow()
fun getAvailableExtensionsFlow(): Flow<List<Extension.Available>> {
return availableExtensionsFlow.asSharedFlow()
}
private var availableExtensionsSourcesData: Map<Long, SourceData> = mapOf()