From b4e971559221e951cf9a5afcb071ace5a7c14b8f Mon Sep 17 00:00:00 2001 From: vfsfitvnm Date: Mon, 6 Jun 2022 16:02:04 +0200 Subject: [PATCH] Fix a bug which caused a song collection to not display in HomeScreen --- .../kotlin/it/vfsfitvnm/vimusic/ui/screens/HomeScreen.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/HomeScreen.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/HomeScreen.kt index 0932a4a..5afa5ad 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/HomeScreen.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/HomeScreen.kt @@ -47,6 +47,7 @@ import it.vfsfitvnm.vimusic.ui.views.PlaylistPreviewItem import it.vfsfitvnm.vimusic.ui.views.SongItem import it.vfsfitvnm.vimusic.utils.* import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.launch @ExperimentalAnimationApi @@ -75,7 +76,11 @@ fun HomeScreen(intentVideoId: String?) { val preferences = LocalPreferences.current - val songCollection by remember(preferences.homePageSongCollection) { + val songCollection by remember(preferences.isReady, preferences.homePageSongCollection) { + if (!preferences.isReady) { + return@remember flowOf(emptyList()) + } + when (preferences.homePageSongCollection) { SongCollection.MostPlayed -> Database.mostPlayed() SongCollection.Favorites -> Database.favorites()