Skip to content

Commit

Permalink
Resolved comments
Browse files Browse the repository at this point in the history
- Inlined `ACESS_TOKEN`.
- Removed TODO.
- Fixed annotations.
  • Loading branch information
imashnake0 committed Jan 15, 2024
1 parent 457e3cf commit 9851b23
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.first
import javax.inject.Named
import javax.inject.Qualifier
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object AnilistApiModule {

// TODO: Name this so we can have other apollo clients for different APIs.
@Provides
@Singleton
@Named("unauthorized")
fun provideApolloClient(
@ApplicationContext context: Context
): ApolloClient {
Expand All @@ -46,7 +44,7 @@ object AnilistApiModule {

@Provides
@Singleton
@Named("authorized")
@Authorized
fun provideAuthorizedApolloClient(
@ApplicationContext context: Context,
httpInterceptor: HttpInterceptor
Expand Down Expand Up @@ -81,3 +79,7 @@ object AnilistApiModule {
}
}
}

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class Authorized
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import javax.inject.Inject
import javax.inject.Named

class AnilistMediaRepository @Inject constructor(
@Named("unauthorized") private val apolloClient: ApolloClient
private val apolloClient: ApolloClient
) {

fun fetchMediaList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import javax.inject.Inject
import javax.inject.Named

class AnilistSearchRepository @Inject constructor(
@Named("unauthorized") private val apolloClient: ApolloClient
private val apolloClient: ApolloClient
) {
fun fetchSearch(
type: MediaType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import javax.inject.Inject
import javax.inject.Named

class AnilistUserRepository @Inject constructor(
@Named("authorized") private val apolloClient: ApolloClient
@Authorized private val apolloClient: ApolloClient
) {
fun fetchViewer(): Flow<Result<ViewerQuery.Viewer>> {
return apolloClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import com.imashnake.animite.api.preferences.ext.getValue
import com.imashnake.animite.api.preferences.ext.setValue
import javax.inject.Inject

private const val ACCESS_TOKEN = "access_token"

class PreferencesRepository @Inject constructor(
private val dataStore: DataStore<Preferences>
) {
private val accessTokenKey = stringPreferencesKey(ACCESS_TOKEN)
private val accessTokenKey = stringPreferencesKey("access_token")
val accessToken = dataStore.getValue(accessTokenKey, null)

suspend fun setAccessToken(accessToken: String?) {
Expand Down

0 comments on commit 9851b23

Please sign in to comment.