Skip to content
Permalink
Browse files

Don't show add watch button for unaired eps

  • Loading branch information
chrisbanes committed Mar 3, 2020
1 parent ff20648 commit 6564036698579e07d92897ca226e5f954c10de13
@@ -80,12 +80,16 @@ class EpisodeDetailsViewModel @AssistedInject constructor(
}

private fun updateFromEpisodeDetails(episodeWithSeason: EpisodeWithSeason) = setState {
copy(episode = episodeWithSeason.episode, season = episodeWithSeason.season)
val firstAired = episodeWithSeason.episode?.firstAired
copy(
episode = episodeWithSeason.episode,
season = episodeWithSeason.season,
canAddEpisodeWatch = firstAired?.isBefore(OffsetDateTime.now()) == true
)
}

private fun updateFromEpisodeWatches(watches: List<EpisodeWatchEntry>) = setState {
val action = if (watches.isNotEmpty()) Action.UNWATCH else Action.WATCH
copy(watches = watches, action = action)
copy(watches = watches)
}

fun submitAction(action: EpisodeDetailsAction) {
@@ -26,5 +26,5 @@ data class EpisodeDetailsViewState(
val season: Season? = null,
val episode: Episode? = null,
val watches: List<EpisodeWatchEntry> = emptyList(),
val action: Action = Action.WATCH
val canAddEpisodeWatch: Boolean = false
) : MvRxState
@@ -144,16 +144,12 @@ private fun EpisodeDetails(

val watches = viewState.watches

if (watches.isEmpty()) {
MarkWatchedButton(
modifier = LayoutGravity.Center,
actioner = actioner
)
} else {
AddWatchButton(
modifier = LayoutGravity.Center,
actioner = actioner
)
if (viewState.canAddEpisodeWatch) {
if (watches.isEmpty()) {
MarkWatchedButton(modifier = LayoutGravity.Center, actioner = actioner)
} else {
AddWatchButton(modifier = LayoutGravity.Center, actioner = actioner)
}
}

Spacer(modifier = LayoutHeight(16.dp))

0 comments on commit 6564036

Please sign in to comment.
You can’t perform that action at this time.