From aeedee1066b8c3c1cd5f5bd05db7835bf44aff2d Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Tue, 20 Jul 2021 00:39:25 +0200 Subject: [PATCH] Show default codec conversion if it's not set (#212) --- .../accentor/ui/preferences/PreferencesViewModel.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/me/vanpetegem/accentor/ui/preferences/PreferencesViewModel.kt b/app/src/main/java/me/vanpetegem/accentor/ui/preferences/PreferencesViewModel.kt index 41c4c552..a8f99d97 100644 --- a/app/src/main/java/me/vanpetegem/accentor/ui/preferences/PreferencesViewModel.kt +++ b/app/src/main/java/me/vanpetegem/accentor/ui/preferences/PreferencesViewModel.kt @@ -27,8 +27,10 @@ class PreferencesViewModel(application: Application) : AndroidViewModel(applicat val server: LiveData = authenticationRepository.server val imageCacheSize: LiveData = preferencesDataSource.imageCacheSize val musicCacheSize: LiveData = preferencesDataSource.musicCacheSize - val conversion: LiveData = switchMap(codecConversionRepository.allCodecConversionsById) { ccs -> - map(conversionId) { it?.let { ccs[it] } } + val conversion: LiveData = switchMap(codecConversionRepository.allCodecConversionsById) { ccsMap -> + switchMap(codecConversionRepository.allCodecConversions) { ccs -> + map(conversionId) { it?.let { ccsMap[it] } ?: ccs.firstOrNull() } + } } val possibleConversions = codecConversionRepository.allCodecConversions