mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Fix library not loading when not logged in to any tracker (#8629)
This commit is contained in:
parent
28bceffc6f
commit
217b03a292
1 changed files with 12 additions and 7 deletions
|
@ -52,6 +52,7 @@ import kotlinx.coroutines.flow.collectLatest
|
|||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
@ -417,14 +418,18 @@ class LibraryScreenModel(
|
|||
*/
|
||||
private fun getTrackingFilterFlow(): Flow<Map<Long, Int>> {
|
||||
val loggedServices = trackManager.services.filter { it.isLogged }
|
||||
val a = loggedServices
|
||||
return if (loggedServices.isNotEmpty()) {
|
||||
val prefFlows = loggedServices
|
||||
.map { libraryPreferences.filterTracking(it.id.toInt()).changes() }
|
||||
.toTypedArray()
|
||||
return combine(*a) {
|
||||
combine(*prefFlows) {
|
||||
loggedServices
|
||||
.mapIndexed { index, trackService -> trackService.id to it[index] }
|
||||
.toMap()
|
||||
}
|
||||
} else {
|
||||
flowOf(emptyMap())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue