Skip to content
Permalink
Browse files

Merge pull request #357 from chrisbanes/cb/reset-database

Don't check responseModified flag
  • Loading branch information...
chrisbanes committed Jul 8, 2019
2 parents ce0bfdd + 143f5a0 commit 40dea42e7a819ccba3ab8e35bc0d0db2b8437305

Large diffs are not rendered by default.

@@ -63,9 +63,8 @@ class SeasonsEpisodesRepository @Inject constructor(
}

suspend fun updateSeasonsEpisodes(showId: Long) {
val result = traktSeasonsDataSource.getSeasonsEpisodes(showId)
when {
result is Success && result.responseModified -> {
when (val result = traktSeasonsDataSource.getSeasonsEpisodes(showId)) {
is Success -> {
result.data.distinctBy { it.first.number }.associate { (season, episodes) ->
val localSeason = seasonsEpisodesStore.getSeasonWithTraktId(season.traktId!!)
?: Season(showId = showId)
@@ -115,8 +115,8 @@ class FollowedShowsRepository @Inject constructor(
private suspend fun pullDownTraktFollowedList(listId: Int) {
val response = dataSource.getListShows(listId)
logger.d("pullDownTraktFollowedList. Response: %s", response)
when {
response is Success && response.responseModified -> {
when (response) {
is Success -> {
response.data.map { (entry, show) ->
// Grab the show id if it exists, or save the show and use it's generated ID
val showId = showStore.getIdOrSavePlaceholder(show)
@@ -47,9 +47,8 @@ class PopularShowsRepository @Inject constructor(
}

private suspend fun updatePopularShows(page: Int, resetOnSave: Boolean) {
val response = traktDataSource.getPopularShows(page, 20)
when {
response is Success && response.responseModified -> {
when (val response = traktDataSource.getPopularShows(page, 20)) {
is Success -> {
response.data.map { (show, entry) ->
// Grab the show id if it exists, or save the show and use it's generated ID
val showId = showStore.getIdOrSavePlaceholder(show)
@@ -46,14 +46,14 @@ class RelatedShowsRepository @Inject constructor(

suspend fun updateRelatedShows(showId: Long) {
val tmdbResults = tmdbDataSource.getRelatedShows(showId)
if (tmdbResults is Success && tmdbResults.responseModified && tmdbResults.data.isNotEmpty()) {
if (tmdbResults is Success && tmdbResults.data.isNotEmpty()) {
process(showId, tmdbResults.data)
lastRequestStore.updateLastRequest(showId)
return
}

val traktResults = traktDataSource.getRelatedShows(showId)
if (traktResults is Success && traktResults.responseModified && traktResults.data.isNotEmpty()) {
if (traktResults is Success && traktResults.data.isNotEmpty()) {
process(showId, traktResults.data)
lastRequestStore.updateLastRequest(showId)
return
@@ -31,9 +31,8 @@ class TraktUsersRepository @Inject constructor(
fun observeUser(username: String) = traktUsersStore.observeUser(username)

suspend fun updateUser(username: String) {
val response = traktDataSource.getUser(username)
when {
response is Success && response.responseModified -> {
when (val response = traktDataSource.getUser(username)) {
is Success -> {
var user = response.data
// Tag the user as 'me' if that's what we're requesting
if (username == "me") {
@@ -44,9 +44,8 @@ class TrendingShowsRepository @Inject constructor(
}

private suspend fun updateTrendingShows(page: Int, resetOnSave: Boolean) {
val response = traktDataSource.getTrendingShows(page, 20)
when {
response is Success && response.responseModified -> {
when (val response = traktDataSource.getTrendingShows(page, 20)) {
is Success -> {
response.data.map { (show, entry) ->
// Grab the show id if it exists, or save the show and use it's generated ID
val showId = showStore.getIdOrSavePlaceholder(show)
@@ -45,9 +45,8 @@ class WatchedShowsRepository @Inject constructor(
suspend fun getWatchedShows() = watchedShowsStore.getWatchedShows()

suspend fun updateWatchedShows() {
val response = traktDataSource.getWatchedShows()
when {
response is Success && response.responseModified -> {
when (val response = traktDataSource.getWatchedShows()) {
is Success -> {
response.data.map { (show, entry) ->
// Grab the show id if it exists, or save the show and use it's generated ID
val watchedShowId = showStore.getIdOrSavePlaceholder(show)

0 comments on commit 40dea42

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