fix some small bugs

This commit is contained in:
Owen LeJeune
2023-07-08 20:48:49 -04:00
parent 2712561a31
commit bcb856bdf5
2 changed files with 23 additions and 18 deletions

View File

@@ -120,6 +120,11 @@ class TmdbClient: KoinComponent {
builder.addQueryParams(languageParam, regionParam)
}
if (shouldIncludeSessionIdParam(segments)) {
val sessionIdParam = QueryParam("session_id", SessionManager.currentSession.value!!.sessionId)
builder.addQueryParams(sessionIdParam)
}
val requestBuilder = chain.request().newBuilder().url(builder.build())
val request = requestBuilder.build()
@@ -151,6 +156,15 @@ class TmdbClient: KoinComponent {
return true
}
private fun shouldIncludeSessionIdParam(urlSegments: List<String>): Boolean {
val includedRoutes = listOf("account_states")
for (route in includedRoutes) {
if (urlSegments.contains(route)) {
return true
}
}
return false
}
}
private inner class V4Interceptor: Interceptor {

View File

@@ -32,50 +32,41 @@ class AccountViewModel: ViewModel(), KoinComponent {
val listMap = listService.listMap
val ratedTv: Flow<PagingData<Any>>
get() = createPagingFlow(
val ratedTv: Flow<PagingData<Any>> = createPagingFlow(
fetcher = { p -> accountV4Service.getRatedTvShows(accountId, p) },
processor = { it.results }
)
val favoriteTv: Flow<PagingData<Any>>
get() = createPagingFlow(
val favoriteTv: Flow<PagingData<Any>> = createPagingFlow(
fetcher = { p -> accountV4Service.getFavoriteTvShows(accountId, p) },
processor = { it.results }
)
val watchlistTv: Flow<PagingData<Any>>
get() = createPagingFlow(
val watchlistTv: Flow<PagingData<Any>> = createPagingFlow(
fetcher = { p -> accountV4Service.getTvShowWatchlist(accountId, p) },
processor = { it.results }
)
val recommendedTv: Flow<PagingData<Any>>
get() = createPagingFlow(
val recommendedTv: Flow<PagingData<Any>> = createPagingFlow(
fetcher = { p -> accountV4Service.getRecommendedTvSeries(accountId, p) },
processor = { it.results }
)
val ratedMovies: Flow<PagingData<Any>>
get() = createPagingFlow(
val ratedMovies: Flow<PagingData<Any>> = createPagingFlow(
fetcher = { p -> accountV4Service.getRatedMovies(accountId, p) },
processor = { it.results }
)
val favoriteMovies: Flow<PagingData<Any>>
get() = createPagingFlow(
val favoriteMovies: Flow<PagingData<Any>> = createPagingFlow(
fetcher = { p -> accountV4Service.getFavoriteMovies(accountId, p) },
processor = { it.results }
)
val watchlistMovies: Flow<PagingData<Any>>
get() = createPagingFlow(
val watchlistMovies: Flow<PagingData<Any>> = createPagingFlow(
fetcher = { p -> accountV4Service.getMovieWatchlist(accountId, p) },
processor = { it.results }
)
val recommendedMovies: Flow<PagingData<Any>>
get() = createPagingFlow(
val recommendedMovies: Flow<PagingData<Any>> = createPagingFlow(
fetcher = { p -> accountV4Service.getRecommendedMovies(accountId, p) },
processor = { it.results }
)
val userLists: Flow<PagingData<Any>>
get() = createPagingFlow(
val userLists: Flow<PagingData<Any>> = createPagingFlow(
fetcher = { p -> accountV4Service.getLists(accountId, p) },
processor = { it.results }
)