|
|
@ -52,6 +52,7 @@ import kotlinx.coroutines.flow.collectLatest
|
|
|
|
import kotlinx.coroutines.flow.combine
|
|
|
|
import kotlinx.coroutines.flow.combine
|
|
|
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
|
|
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
|
|
|
import kotlinx.coroutines.flow.first
|
|
|
|
import kotlinx.coroutines.flow.first
|
|
|
|
|
|
|
|
import kotlinx.coroutines.flow.flowOf
|
|
|
|
import kotlinx.coroutines.flow.launchIn
|
|
|
|
import kotlinx.coroutines.flow.launchIn
|
|
|
|
import kotlinx.coroutines.flow.map
|
|
|
|
import kotlinx.coroutines.flow.map
|
|
|
|
import kotlinx.coroutines.flow.onEach
|
|
|
|
import kotlinx.coroutines.flow.onEach
|
|
|
@ -417,13 +418,17 @@ class LibraryScreenModel(
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private fun getTrackingFilterFlow(): Flow<Map<Long, Int>> {
|
|
|
|
private fun getTrackingFilterFlow(): Flow<Map<Long, Int>> {
|
|
|
|
val loggedServices = trackManager.services.filter { it.isLogged }
|
|
|
|
val loggedServices = trackManager.services.filter { it.isLogged }
|
|
|
|
val a = loggedServices
|
|
|
|
return if (loggedServices.isNotEmpty()) {
|
|
|
|
.map { libraryPreferences.filterTracking(it.id.toInt()).changes() }
|
|
|
|
val prefFlows = loggedServices
|
|
|
|
.toTypedArray()
|
|
|
|
.map { libraryPreferences.filterTracking(it.id.toInt()).changes() }
|
|
|
|
return combine(*a) {
|
|
|
|
.toTypedArray()
|
|
|
|
loggedServices
|
|
|
|
combine(*prefFlows) {
|
|
|
|
.mapIndexed { index, trackService -> trackService.id to it[index] }
|
|
|
|
loggedServices
|
|
|
|
.toMap()
|
|
|
|
.mapIndexed { index, trackService -> trackService.id to it[index] }
|
|
|
|
|
|
|
|
.toMap()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
flowOf(emptyMap())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|