Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Fix Discover not refreshing #1432

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@ class PopularShowsStore(
writeDispatcher = dispatchers.databaseWrite,
),
).validator(
Validator.by { lastRequestStore.isRequestValid(3.hours) },
Validator.by {
it.isNotEmpty() && lastRequestStore.isRequestValid(3.hours)
},
).build()
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ class RecommendedShowsStore(
writeDispatcher = dispatchers.databaseWrite,
),
).validator(
Validator.by { lastRequestStore.isRequestValid(3.days) },
Validator.by { it.isNotEmpty() && lastRequestStore.isRequestValid(3.days) },
).build()
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ class RelatedShowsStore(
writeDispatcher = dispatchers.databaseWrite,
),
).validator(
Validator.by { lastRequestStore.isRequestValid(it.showId, 28.days) },
Validator.by {
it.related.isNotEmpty() && lastRequestStore.isRequestValid(it.showId, 28.days)
},
).build()

data class RelatedShows(val showId: Long, val related: List<RelatedShowEntry>)
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,7 @@ class ShowImagesStore(
writeDispatcher = dispatchers.databaseWrite,
),
).validator(
Validator.by { lastRequestStore.isRequestValid(it.showId, 180.days) },
Validator.by {
it.images.isNotEmpty() && lastRequestStore.isRequestValid(it.showId, 180.days)
},
).build()
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ class TrendingShowsStore(
writeDispatcher = dispatchers.databaseWrite,
),
).validator(
Validator.by { lastRequestStore.isRequestValid(3.hours) },
Validator.by { it.isNotEmpty() && lastRequestStore.isRequestValid(3.hours) },
).build()
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ class WatchedShowsStore(
writeDispatcher = dispatchers.databaseWrite,
),
).validator(
Validator.by { lastRequestStore.isRequestValid(6.hours) },
Validator.by { it.isNotEmpty() && lastRequestStore.isRequestValid(6.hours) },
).build()
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,17 @@ class DiscoverPresenter(
}
}

LaunchedEffect(authState) {
LaunchedEffect(Unit) {
observeTrendingShows(ObserveTrendingShows.Params(10))
observePopularShows(ObservePopularShows.Params(10))
observeRecommendedShows(ObserveRecommendedShows.Params(10))
observeNextShowEpisodeToWatch(Unit)
observeTraktAuthState(Unit)
observeUserDetails(ObserveUserDetails.Params("me"))

if (authState == TraktAuthState.LOGGED_IN) {
observeRecommendedShows(ObserveRecommendedShows.Params(10))
}

eventSink(DiscoverUiEvent.Refresh(false))
}

LaunchedEffect(observeTraktAuthState) {
// Each time the auth state changes, tickle the refresh signal...
observeTraktAuthState.flow.collect {
eventSink(DiscoverUiEvent.Refresh(false))
}
LaunchedEffect(authState) {
eventSink(DiscoverUiEvent.Refresh(false))
}

return DiscoverUiState(
Expand Down