From 735344d6a438507ef8e9f7b6d5e7b55ff2c16132 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Tue, 3 Sep 2024 15:53:53 +0200 Subject: [PATCH] Clean code --- .../managers/AppSettingsManager.kt | 8 ++++---- .../database/cache/setting/AppSettingsController.kt | 3 +-- .../network/requests/BaseRequest.kt | 6 +----- .../network/serializers/IntToBooleanSerializer.kt | 6 +----- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/AppSettingsManager.kt b/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/AppSettingsManager.kt index 1c6d155a..340c8bec 100644 --- a/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/AppSettingsManager.kt +++ b/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/AppSettingsManager.kt @@ -55,7 +55,7 @@ class AppSettingsManager internal constructor( * @throws IllegalArgumentException If the provided theme is invalid. * @throws CancellationException If the operation is cancelled. */ - @Throws(IllegalArgumentException::class, CancellationException::class) + @Throws(IllegalArgumentException::class, CancellationException::class) suspend fun setTheme(theme: Theme) = withContext(Dispatchers.IO) { appSettingsController.setTheme(theme) } @@ -68,7 +68,7 @@ class AppSettingsManager internal constructor( * @throws IllegalArgumentException If the provided validity period is invalid. * @throws CancellationException If the operation is cancelled. */ - @Throws(IllegalArgumentException::class, CancellationException::class) + @Throws(IllegalArgumentException::class, CancellationException::class) suspend fun setValidityPeriod(validityPeriod: ValidityPeriod) = withContext(Dispatchers.IO) { appSettingsController.setValidityPeriod(validityPeriod) } @@ -81,7 +81,7 @@ class AppSettingsManager internal constructor( * @throws IllegalArgumentException If the provided download limit is invalid. * @throws CancellationException If the operation is cancelled. */ - @Throws(IllegalArgumentException::class, CancellationException::class) + @Throws(IllegalArgumentException::class, CancellationException::class) suspend fun setDownloadLimit(downloadLimit: DownloadLimit) = withContext(Dispatchers.IO) { appSettingsController.setDownloadLimit(downloadLimit) } @@ -94,7 +94,7 @@ class AppSettingsManager internal constructor( * @throws IllegalArgumentException If the provided email language is invalid. * @throws CancellationException If the operation is cancelled. */ - @Throws(IllegalArgumentException::class, CancellationException::class) + @Throws(IllegalArgumentException::class, CancellationException::class) suspend fun setEmailLanguage(emailLanguage: EmailLanguage) = withContext(Dispatchers.IO) { appSettingsController.setEmailLanguage(emailLanguage) } diff --git a/STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/cache/setting/AppSettingsController.kt b/STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/cache/setting/AppSettingsController.kt index 2f648340..947c28e8 100644 --- a/STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/cache/setting/AppSettingsController.kt +++ b/STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/cache/setting/AppSettingsController.kt @@ -18,7 +18,6 @@ package com.infomaniak.multiplatform_swisstransfer.database.cache.setting -import com.infomaniak.multiplatform_swisstransfer.common.interfaces.appSettings.AppSettings import com.infomaniak.multiplatform_swisstransfer.common.models.DownloadLimit import com.infomaniak.multiplatform_swisstransfer.common.models.EmailLanguage import com.infomaniak.multiplatform_swisstransfer.common.models.Theme @@ -27,10 +26,10 @@ import com.infomaniak.multiplatform_swisstransfer.database.RealmProvider import com.infomaniak.multiplatform_swisstransfer.database.models.setting.AppSettingsDB import io.realm.kotlin.UpdatePolicy import io.realm.kotlin.ext.query -import kotlin.coroutines.cancellation.CancellationException import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.mapLatest +import kotlin.coroutines.cancellation.CancellationException @OptIn(ExperimentalCoroutinesApi::class) class AppSettingsController(private val realmProvider: RealmProvider) { diff --git a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/BaseRequest.kt b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/BaseRequest.kt index ca713fd9..dbc0c34d 100644 --- a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/BaseRequest.kt +++ b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/BaseRequest.kt @@ -20,11 +20,7 @@ package com.infomaniak.multiplatform_swisstransfer.network.requests import com.infomaniak.multiplatform_swisstransfer.network.utils.ApiRoutes import io.ktor.client.HttpClient -import io.ktor.client.request.delete -import io.ktor.client.request.get -import io.ktor.client.request.post -import io.ktor.client.request.put -import io.ktor.client.request.setBody +import io.ktor.client.request.* import io.ktor.client.statement.HttpResponse import io.ktor.client.statement.bodyAsText import io.ktor.http.URLBuilder diff --git a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/serializers/IntToBooleanSerializer.kt b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/serializers/IntToBooleanSerializer.kt index f1581575..5f475b35 100644 --- a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/serializers/IntToBooleanSerializer.kt +++ b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/serializers/IntToBooleanSerializer.kt @@ -19,11 +19,7 @@ package com.infomaniak.multiplatform_swisstransfer.network.serializers import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.json.JsonElement -import kotlinx.serialization.json.JsonPrimitive -import kotlinx.serialization.json.JsonTransformingSerializer -import kotlinx.serialization.json.int -import kotlinx.serialization.json.jsonPrimitive +import kotlinx.serialization.json.* internal object IntToBooleanSerializer : JsonTransformingSerializer(Boolean.serializer()) { override fun transformDeserialize(element: JsonElement): JsonElement {