Skip to content

Commit

Permalink
update on login
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed May 13, 2024
1 parent 07e4000 commit 1a6cd85
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ import kotlinx.coroutines.flow.*

class CharacterRepository(
private val client: ApolloClient,
private val fallbackClient: ApolloClient
private val fallbackClient: ApolloClient,
private val isLoggedIn: Flow<Boolean>
) {

private val id = MutableStateFlow<Int?>(null)
private val query = id.filterNotNull().map {
Query(it)
private val query = combine(
id.filterNotNull(),
isLoggedIn.distinctUntilChanged()
) { t1, _ ->
Query(t1)
}
private val fallbackQuery = query.transform {
return@transform emitAll(fallbackClient.query(it.toGraphQL()).toFlow())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ import kotlinx.coroutines.flow.*

class MediumRepository(
private val client: ApolloClient,
private val fallbackClient: ApolloClient
private val fallbackClient: ApolloClient,
private val isLoggedIn: Flow<Boolean>
) {

private val id = MutableStateFlow<Int?>(null)
private val query = id.filterNotNull().map {
Query(it)
private val query = combine(
id.filterNotNull(),
isLoggedIn.distinctUntilChanged()
) { t1, _ ->
Query(t1)
}
private val fallbackQuery = query.transform {
return@transform emitAll(fallbackClient.query(it.toGraphQL()).toFlow())
Expand Down
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ allprojects {

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = CompileOptions.jvmTarget
compilerOptions {
freeCompilerArgs.addAll(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:experimentalStrongSkipping=true"
)
}
}
plugins.withType<YarnPlugin> {
yarn.yarnLockAutoReplace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ data object NetworkModule {
CharacterRepository(
client = instance<ApolloClient>(Constants.AniList.APOLLO_CLIENT).newBuilder().fetchPolicy(FetchPolicy.NetworkFirst).build(),
fallbackClient = instance<ApolloClient>(Constants.AniList.FALLBACK_APOLLO_CLIENT).newBuilder().fetchPolicy(FetchPolicy.NetworkFirst).build(),
isLoggedIn = instance<UserHelper>().isLoggedIn
)
}
bindSingleton<MediumRepository> {
MediumRepository(
client = instance<ApolloClient>(Constants.AniList.APOLLO_CLIENT).newBuilder().fetchPolicy(FetchPolicy.NetworkFirst).build(),
fallbackClient = instance<ApolloClient>(Constants.AniList.FALLBACK_APOLLO_CLIENT).newBuilder().fetchPolicy(FetchPolicy.NetworkFirst).build()
fallbackClient = instance<ApolloClient>(Constants.AniList.FALLBACK_APOLLO_CLIENT).newBuilder().fetchPolicy(FetchPolicy.NetworkFirst).build(),
isLoggedIn = instance<UserHelper>().isLoggedIn
)
}
bindSingleton<TraceRepository> {
Expand Down

0 comments on commit 1a6cd85

Please sign in to comment.