Skip to content

Commit

Permalink
Use cache if available
Browse files Browse the repository at this point in the history
Need to do this to stop triggering rate limits every couple minutes.
  • Loading branch information
imashnake0 committed Feb 17, 2024
1 parent 8f5ac8c commit 15241f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AnilistMediaRepository @Inject constructor(
seasonYear = Optional.presentIfNotNull(seasonYear)
)
)
.fetchPolicy(FetchPolicy.CacheAndNetwork)
.fetchPolicy(FetchPolicy.CacheFirst)
.toFlow()
.asResult {
it.page!!.media.orEmpty().filterNotNull().map { query -> Media.Medium(query) }
Expand All @@ -57,7 +57,7 @@ class AnilistMediaRepository @Inject constructor(
type = Optional.presentIfNotNull(mediaType)
)
)
.fetchPolicy(FetchPolicy.CacheAndNetwork)
.fetchPolicy(FetchPolicy.CacheFirst)
.toFlow()
.asResult { Media(it.media!!) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AnilistUserRepository @Inject constructor(
fun fetchViewer(): Flow<Result<ViewerQuery.Viewer>> {
return apolloClient
.query(ViewerQuery())
.fetchPolicy(FetchPolicy.CacheAndNetwork)
.fetchPolicy(FetchPolicy.CacheFirst)
.toFlow()
.asResult { it.viewer!! }
}
Expand Down

0 comments on commit 15241f9

Please sign in to comment.