From a5a8e9e69e194635d7ddb01c3fab4338b542455c Mon Sep 17 00:00:00 2001 From: Fabian Devel Date: Tue, 17 Dec 2024 15:50:17 +0100 Subject: [PATCH] refactor(RecipientEmails): Make the recipientEmails field a Set instead of a list --- .../common/interfaces/upload/UploadSession.kt | 2 +- .../multiplatform_swisstransfer/data/NewUploadSession.kt | 2 +- .../database/models/upload/UploadSessionDB.kt | 6 ++++-- .../database/dataset/DummyUpload.kt | 2 +- .../network/models/upload/request/FinishUploadBody.kt | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/STCommon/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/common/interfaces/upload/UploadSession.kt b/STCommon/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/common/interfaces/upload/UploadSession.kt index e8f7678a..02f35f9a 100644 --- a/STCommon/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/common/interfaces/upload/UploadSession.kt +++ b/STCommon/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/common/interfaces/upload/UploadSession.kt @@ -30,7 +30,7 @@ interface UploadSession { val message: String val numberOfDownload: DownloadLimit get() = DownloadLimit.TWO_HUNDRED_FIFTY val language: EmailLanguage - val recipientsEmails: List + val recipientsEmails: Set val files: List // Remote diff --git a/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/data/NewUploadSession.kt b/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/data/NewUploadSession.kt index 880a23a4..ec1edbc2 100644 --- a/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/data/NewUploadSession.kt +++ b/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/data/NewUploadSession.kt @@ -32,7 +32,7 @@ data class NewUploadSession( override val message: String, override val numberOfDownload: DownloadLimit, override val language: EmailLanguage, - override val recipientsEmails: List, + override val recipientsEmails: Set, override val files: List, ) : UploadSession { override val uuid: String = "" diff --git a/STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/models/upload/UploadSessionDB.kt b/STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/models/upload/UploadSessionDB.kt index c1febe5c..ae37eb2a 100644 --- a/STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/models/upload/UploadSessionDB.kt +++ b/STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/models/upload/UploadSessionDB.kt @@ -23,8 +23,10 @@ import com.infomaniak.multiplatform_swisstransfer.common.models.EmailLanguage import com.infomaniak.multiplatform_swisstransfer.common.models.ValidityPeriod import com.infomaniak.multiplatform_swisstransfer.database.models.appSettings.AppSettingsDB import io.realm.kotlin.ext.realmListOf +import io.realm.kotlin.ext.realmSetOf import io.realm.kotlin.types.RealmList import io.realm.kotlin.types.RealmObject +import io.realm.kotlin.types.RealmSet import io.realm.kotlin.types.RealmUUID import io.realm.kotlin.types.annotations.PrimaryKey @@ -37,7 +39,7 @@ class UploadSessionDB() : UploadSession, RealmObject { override var password: String = "" override var message: String = "" private var _numberOfDownload: Int = AppSettingsDB.DEFAULT_DOWNLOAD_LIMIT.value - override var recipientsEmails: RealmList = realmListOf() + override var recipientsEmails: RealmSet = realmSetOf() override var files: RealmList = realmListOf() private var _language: String = "" @@ -62,7 +64,7 @@ class UploadSessionDB() : UploadSession, RealmObject { this.message = uploadSession.message this._numberOfDownload = uploadSession.numberOfDownload.value this.language = uploadSession.language - this.recipientsEmails = realmListOf(*uploadSession.recipientsEmails.toTypedArray()) + this.recipientsEmails = realmSetOf(*uploadSession.recipientsEmails.toTypedArray()) this.files = uploadSession.files.mapTo(realmListOf(), ::UploadFileSessionDB) } } diff --git a/STDatabase/src/commonTest/kotlin/com/infomaniak/multiplatform_swisstransfer/database/dataset/DummyUpload.kt b/STDatabase/src/commonTest/kotlin/com/infomaniak/multiplatform_swisstransfer/database/dataset/DummyUpload.kt index a38f04d4..25a7ac2d 100644 --- a/STDatabase/src/commonTest/kotlin/com/infomaniak/multiplatform_swisstransfer/database/dataset/DummyUpload.kt +++ b/STDatabase/src/commonTest/kotlin/com/infomaniak/multiplatform_swisstransfer/database/dataset/DummyUpload.kt @@ -49,7 +49,7 @@ object DummyUpload { override val message: String = "" override val numberOfDownload: DownloadLimit = DownloadLimit.ONE override val language: EmailLanguage = EmailLanguage.ITALIAN - override val recipientsEmails: List = emptyList() + override val recipientsEmails: Set = emptySet() override val files: List = emptyList() override val remoteContainer: UploadContainer? = null override val remoteUploadHost: String? = null diff --git a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/models/upload/request/FinishUploadBody.kt b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/models/upload/request/FinishUploadBody.kt index fbdb0e70..2cbdcd58 100644 --- a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/models/upload/request/FinishUploadBody.kt +++ b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/models/upload/request/FinishUploadBody.kt @@ -26,5 +26,5 @@ data class FinishUploadBody( val containerUUID: String = "", @SerialName("lang") val language: String = "", - val recipientsEmails: List? = null, + val recipientsEmails: Set? = null, )