Skip to content

Commit

Permalink
feat(tv-show): skip loading TV show's 'Specials' season
Browse files Browse the repository at this point in the history
Close #91
  • Loading branch information
stantanasi committed Apr 18, 2024
1 parent dd845ce commit 2cb73a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ class TvShowViewHolder(
?: episodes.indexOfLast { it.isWatched }
.takeIf { it != -1 && it + 1 < episodes.size }
?.let { episodes.getOrNull(it + 1) }
?: tvShow.seasons.firstOrNull { it.number != 0 }?.episodes?.firstOrNull()
?: episodes.firstOrNull()

binding.btnTvShowWatchEpisode.apply {
Expand Down Expand Up @@ -718,8 +719,8 @@ class TvShowViewHolder(
?: episodes.indexOfLast { it.isWatched }
.takeIf { it != -1 && it + 1 < episodes.size }
?.let { episodes.getOrNull(it + 1) }
?: tvShow.seasons.firstOrNull { it.number != 0 }?.episodes?.firstOrNull()
?: episodes.firstOrNull()
episode?.season = episode?.season?.let { database.seasonDao().getById(it.id) }

binding.btnTvShowWatchEpisode.apply {
setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class TvShowViewModel(id: String, private val database: AppDatabase) : ViewModel
}

if (episodes.isEmpty() && state.tvShow.seasons.isNotEmpty()) {
getSeason(TvShow(id, ""), state.tvShow.seasons.first())
val firstSeason = state.tvShow.seasons.firstOrNull { it.number != 0 }
?: state.tvShow.seasons.first()
getSeason(TvShow(id, ""), firstSeason)
} else {
val season = state.tvShow.seasons.let { seasons ->
seasons
Expand Down

0 comments on commit 2cb73a6

Please sign in to comment.