File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Jetcaster/app/src/main/java/com/example/jetcaster/ui/home Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 16
16
17
17
package com.example.jetcaster.ui.home
18
18
19
+ import android.util.Log
19
20
import androidx.lifecycle.ViewModel
20
21
import androidx.lifecycle.viewModelScope
21
22
import com.example.jetcaster.Graph
@@ -60,14 +61,19 @@ class HomeViewModel(
60
61
private val refreshing = MutableStateFlow (false )
61
62
62
63
@OptIn(ExperimentalCoroutinesApi ::class )
63
- private val libraryEpisodes = podcastStore.followedPodcastsSortedByLastEpisode()
64
+ private val libraryEpisodes =
65
+ podcastStore.followedPodcastsSortedByLastEpisode()
64
66
.flatMapLatest { followedPodcasts ->
65
- combine(
66
- followedPodcasts.map { p ->
67
- episodeStore.episodesInPodcast(p.podcast.uri, 5 )
67
+ if (followedPodcasts.isEmpty()) {
68
+ flowOf(emptyList())
69
+ } else {
70
+ combine(
71
+ followedPodcasts.map { p ->
72
+ episodeStore.episodesInPodcast(p.podcast.uri, 5 )
73
+ }
74
+ ) { allEpisodes ->
75
+ allEpisodes.toList().flatten().sortedByDescending { it.episode.published }
68
76
}
69
- ) { allEpisodes ->
70
- allEpisodes.toList().flatten().sortedByDescending { it.episode.published }
71
77
}
72
78
}
73
79
You can’t perform that action at this time.
0 commit comments