Skip to content

Commit

Permalink
refactor(RecipientEmails): Make the recipientEmails field a Set inste…
Browse files Browse the repository at this point in the history
…ad of a list
  • Loading branch information
FabianDevel committed Dec 17, 2024
1 parent 67865ac commit a5a8e9e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface UploadSession {
val message: String
val numberOfDownload: DownloadLimit get() = DownloadLimit.TWO_HUNDRED_FIFTY
val language: EmailLanguage
val recipientsEmails: List<String>
val recipientsEmails: Set<String>
val files: List<UploadFileSession>

// Remote
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ data class NewUploadSession(
override val message: String,
override val numberOfDownload: DownloadLimit,
override val language: EmailLanguage,
override val recipientsEmails: List<String>,
override val recipientsEmails: Set<String>,
override val files: List<UploadFileSession>,
) : UploadSession {
override val uuid: String = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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<String> = realmListOf()
override var recipientsEmails: RealmSet<String> = realmSetOf()
override var files: RealmList<UploadFileSessionDB> = realmListOf()
private var _language: String = ""

Expand All @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = emptyList()
override val recipientsEmails: Set<String> = emptySet()
override val files: List<UploadFileSession> = emptyList()
override val remoteContainer: UploadContainer? = null
override val remoteUploadHost: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ data class FinishUploadBody(
val containerUUID: String = "",
@SerialName("lang")
val language: String = "",
val recipientsEmails: List<String>? = null,
val recipientsEmails: Set<String>? = null,
)

0 comments on commit a5a8e9e

Please sign in to comment.