Skip to content

Commit

Permalink
[Jetcaster] Fix empty screen (#1283)
Browse files Browse the repository at this point in the history
Fix Jetcaster showing an empty screen when the user is not following any
podcasts.
  • Loading branch information
arriolac authored Mar 13, 2024
2 parents ec7cca7 + 5d59c9b commit 4d683f6
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,21 @@ class HomeViewModel(
private val refreshing = MutableStateFlow(false)

@OptIn(ExperimentalCoroutinesApi::class)
private val libraryEpisodes = podcastStore.followedPodcastsSortedByLastEpisode()
.flatMapLatest { followedPodcasts ->
combine(
followedPodcasts.map { p ->
episodeStore.episodesInPodcast(p.podcast.uri, 5)
private val libraryEpisodes =
podcastStore.followedPodcastsSortedByLastEpisode()
.flatMapLatest { followedPodcasts ->
if (followedPodcasts.isEmpty()) {
flowOf(emptyList())
} else {
combine(
followedPodcasts.map { p ->
episodeStore.episodesInPodcast(p.podcast.uri, 5)
}
) { allEpisodes ->
allEpisodes.toList().flatten().sortedByDescending { it.episode.published }
}
}
) { allEpisodes ->
allEpisodes.toList().flatten().sortedByDescending { it.episode.published }
}
}

private val discover = combine(
categoryStore.categoriesSortedByPodcastCount()
Expand Down

0 comments on commit 4d683f6

Please sign in to comment.