Fix a bug which caused a song collection to not display in HomeScreen

This commit is contained in:
vfsfitvnm 2022-06-06 16:02:04 +02:00
parent a56e7181f1
commit b4e9715592

View file

@ -47,6 +47,7 @@ import it.vfsfitvnm.vimusic.ui.views.PlaylistPreviewItem
import it.vfsfitvnm.vimusic.ui.views.SongItem import it.vfsfitvnm.vimusic.ui.views.SongItem
import it.vfsfitvnm.vimusic.utils.* import it.vfsfitvnm.vimusic.utils.*
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ExperimentalAnimationApi @ExperimentalAnimationApi
@ -75,7 +76,11 @@ fun HomeScreen(intentVideoId: String?) {
val preferences = LocalPreferences.current 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) { when (preferences.homePageSongCollection) {
SongCollection.MostPlayed -> Database.mostPlayed() SongCollection.MostPlayed -> Database.mostPlayed()
SongCollection.Favorites -> Database.favorites() SongCollection.Favorites -> Database.favorites()