mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Remove Ktorfit
This commit is contained in:
@@ -65,10 +65,6 @@ dependencies {
|
||||
implementation(libs.ktor.websockets)
|
||||
implementation(libs.ktor.auth)
|
||||
|
||||
// Ktorfit
|
||||
implementation(libs.ktorfit.lib)
|
||||
ksp(libs.ktorfit.ksp)
|
||||
|
||||
// Apollo GraphQL
|
||||
implementation(libs.apollo.runtime)
|
||||
implementation(libs.apollo.engine.ktor)
|
||||
|
||||
@@ -2,7 +2,6 @@ import Config.migrationCode
|
||||
import Config.serverCode
|
||||
import Config.tachideskVersion
|
||||
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type
|
||||
import de.jensklingenberg.ktorfit.gradle.ErrorCheckingMode
|
||||
import org.jetbrains.compose.ComposeExtension
|
||||
import org.jetbrains.compose.ComposePlugin
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
@@ -17,7 +16,6 @@ plugins {
|
||||
alias(libs.plugins.buildkonfig) apply false
|
||||
alias(libs.plugins.moko.gradle) apply false
|
||||
alias(libs.plugins.kotlinter) apply false
|
||||
alias(libs.plugins.ktorfit) apply false
|
||||
alias(libs.plugins.aboutLibraries) apply false
|
||||
alias(libs.plugins.apollo) apply false
|
||||
alias(libs.plugins.versions)
|
||||
@@ -127,12 +125,6 @@ subprojects {
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withType<de.jensklingenberg.ktorfit.gradle.KtorfitGradlePlugin> {
|
||||
configure<de.jensklingenberg.ktorfit.gradle.KtorfitGradleConfiguration> {
|
||||
errorCheckingMode = ErrorCheckingMode.WARNING
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withType<JacocoPlugin> {
|
||||
configure<JacocoPluginExtension> {
|
||||
toolVersion = "0.8.10"
|
||||
|
||||
@@ -69,7 +69,6 @@ kotlin {
|
||||
api(libs.dateTime)
|
||||
implementation(libs.apollo.runtime)
|
||||
implementation(libs.apollo.engine.ktor)
|
||||
implementation(libs.ktorfit.lib)
|
||||
api(projects.core)
|
||||
api(projects.i18n)
|
||||
api(projects.domain)
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
package ca.gosyer.jui.data
|
||||
|
||||
import ca.gosyer.jui.core.lang.addSuffix
|
||||
import ca.gosyer.jui.data.backup.BackupRepositoryImpl
|
||||
import ca.gosyer.jui.data.category.CategoryRepositoryImpl
|
||||
import ca.gosyer.jui.data.chapter.ChapterRepositoryImpl
|
||||
@@ -34,7 +33,6 @@ import ca.gosyer.jui.domain.updates.service.UpdatesRepository
|
||||
import com.apollographql.apollo.ApolloClient
|
||||
import com.apollographql.apollo.network.ws.GraphQLWsProtocol
|
||||
import com.apollographql.ktor.ktorClient
|
||||
import de.jensklingenberg.ktorfit.Ktorfit
|
||||
import io.ktor.http.URLBuilder
|
||||
import io.ktor.http.appendPathSegments
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -42,17 +40,6 @@ import kotlinx.coroutines.IO
|
||||
import me.tatarka.inject.annotations.Provides
|
||||
|
||||
interface DataComponent : SharedDataComponent {
|
||||
@Provides
|
||||
fun ktorfit(
|
||||
http: Http,
|
||||
serverPreferences: ServerPreferences,
|
||||
) = Ktorfit
|
||||
.Builder()
|
||||
.httpClient(http)
|
||||
.converterFactories(FlowConverterFactory())
|
||||
.baseUrl(serverPreferences.serverUrl().get().toString().addSuffix('/'))
|
||||
.build()
|
||||
|
||||
@Provides
|
||||
fun apolloClient(
|
||||
http: Http,
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.jui.data
|
||||
|
||||
import de.jensklingenberg.ktorfit.Ktorfit
|
||||
import de.jensklingenberg.ktorfit.converter.Converter
|
||||
import de.jensklingenberg.ktorfit.converter.KtorfitResult
|
||||
import de.jensklingenberg.ktorfit.converter.TypeData
|
||||
import io.ktor.client.call.body
|
||||
import io.ktor.client.statement.HttpResponse
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.IO
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
|
||||
class FlowConverterFactory : Converter.Factory {
|
||||
private class FlowResponseConverter(
|
||||
val typeData: TypeData,
|
||||
val ktorfit: Ktorfit,
|
||||
) : Converter.ResponseConverter<HttpResponse, Flow<Any?>> {
|
||||
override fun convert(getResponse: suspend () -> HttpResponse): Flow<Any?> =
|
||||
flow {
|
||||
val response = getResponse()
|
||||
|
||||
val convertedBody = ktorfit.nextSuspendResponseConverter(
|
||||
null,
|
||||
typeData.typeArgs.first(),
|
||||
)?.convert(KtorfitResult.Success(response))
|
||||
?: response.body(typeData.typeArgs.first().typeInfo)
|
||||
emit(convertedBody)
|
||||
}.flowOn(Dispatchers.IO)
|
||||
}
|
||||
|
||||
override fun responseConverter(
|
||||
typeData: TypeData,
|
||||
ktorfit: Ktorfit,
|
||||
): Converter.ResponseConverter<HttpResponse, *>? {
|
||||
if (typeData.typeInfo.type == Flow::class) {
|
||||
return FlowResponseConverter(typeData, ktorfit)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun suspendResponseConverter(
|
||||
typeData: TypeData,
|
||||
ktorfit: Ktorfit,
|
||||
): Converter.SuspendResponseConverter<HttpResponse, *>? = null
|
||||
}
|
||||
@@ -65,10 +65,6 @@ dependencies {
|
||||
implementation(libs.ktor.websockets)
|
||||
implementation(libs.ktor.auth)
|
||||
|
||||
// Ktorfit
|
||||
implementation(libs.ktorfit.lib)
|
||||
ksp(libs.ktorfit.ksp)
|
||||
|
||||
// Apollo GraphQL
|
||||
implementation(libs.apollo.runtime)
|
||||
implementation(libs.apollo.engine.ktor)
|
||||
|
||||
@@ -7,7 +7,6 @@ plugins {
|
||||
id(libs.plugins.ksp.get().pluginId)
|
||||
id(libs.plugins.buildkonfig.get().pluginId)
|
||||
id(libs.plugins.kotlinter.get().pluginId)
|
||||
id(libs.plugins.ktorfit.get().pluginId)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@@ -57,7 +56,6 @@ kotlin {
|
||||
languageSettings {
|
||||
optIn("kotlin.RequiresOptIn")
|
||||
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
|
||||
optIn("de.jensklingenberg.ktorfit.internal.InternalKtorfitApi")
|
||||
}
|
||||
}
|
||||
val commonMain by getting {
|
||||
@@ -72,7 +70,6 @@ kotlin {
|
||||
api(libs.ktor.auth)
|
||||
api(libs.ktor.logging)
|
||||
api(libs.ktor.websockets)
|
||||
api(libs.ktorfit.lib)
|
||||
api(libs.okio)
|
||||
api(libs.dateTime)
|
||||
api(compose("org.jetbrains.compose.runtime:runtime"))
|
||||
|
||||
@@ -38,8 +38,6 @@ kotlinInject = "0.7.2"
|
||||
|
||||
# Network
|
||||
ktor = "2.3.12"
|
||||
ktorfit = "2.1.0"
|
||||
ktorfitKsp = "2.1.0-1.0.25"
|
||||
apollo = "4.0.0"
|
||||
apolloKtor = "0.0.2"
|
||||
|
||||
@@ -131,8 +129,6 @@ ktor-serialization-json = { module = "io.ktor:ktor-serialization-kotlinx-json",
|
||||
ktor-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
|
||||
ktor-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" }
|
||||
ktor-auth = { module = "io.ktor:ktor-client-auth", version.ref = "ktor" }
|
||||
ktorfit-lib = { module = "de.jensklingenberg.ktorfit:ktorfit-lib-light", version.ref = "ktorfit" }
|
||||
ktorfit-ksp = { module = "de.jensklingenberg.ktorfit:ktorfit-ksp", version.ref = "ktorfitKsp" }
|
||||
apollo-runtime = { module = "com.apollographql.apollo:apollo-runtime", version.ref = "apollo" }
|
||||
apollo-engine-ktor = { module = "com.apollographql.ktor:apollo-engine-ktor", version.ref = "apolloKtor" }
|
||||
|
||||
@@ -193,7 +189,6 @@ compose = { id = "org.jetbrains.compose", version.ref = "composeGradle" }
|
||||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||
|
||||
# Network
|
||||
ktorfit = { id = "de.jensklingenberg.ktorfit", version.ref = "ktorfit" }
|
||||
apollo = { id = "com.apollographql.apollo", version.ref = "apollo" }
|
||||
|
||||
# Localization
|
||||
|
||||
@@ -9,7 +9,6 @@ plugins {
|
||||
id(libs.plugins.buildkonfig.get().pluginId)
|
||||
id(libs.plugins.kotlinter.get().pluginId)
|
||||
id(libs.plugins.aboutLibraries.get().pluginId)
|
||||
id(libs.plugins.ktorfit.get().pluginId)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@@ -82,9 +81,6 @@ kotlin {
|
||||
implementation(libs.ktor.websockets)
|
||||
implementation(libs.ktor.auth)
|
||||
|
||||
// Ktorfit
|
||||
implementation(libs.ktorfit.lib)
|
||||
|
||||
// Apollo GraphQL
|
||||
implementation(libs.apollo.runtime)
|
||||
implementation(libs.apollo.engine.ktor)
|
||||
@@ -127,7 +123,6 @@ dependencies {
|
||||
"kspUikitX64"
|
||||
).forEach {
|
||||
add(it, libs.kotlinInject.compiler)
|
||||
add(it, libs.ktorfit.ksp)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user