From d7f51687bb384108435e9663c8d3843db37c6c29 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Fri, 27 Sep 2024 09:53:23 +0200 Subject: [PATCH] Add missing parameters in `Mailbox.initLocalValues()` --- .../cache/mailboxInfo/MailboxController.kt | 6 +++++- .../mail/data/models/mailbox/Mailbox.kt | 20 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/infomaniak/mail/data/cache/mailboxInfo/MailboxController.kt b/app/src/main/java/com/infomaniak/mail/data/cache/mailboxInfo/MailboxController.kt index 92b50c0f40..96ae82aabf 100644 --- a/app/src/main/java/com/infomaniak/mail/data/cache/mailboxInfo/MailboxController.kt +++ b/app/src/main/java/com/infomaniak/mail/data/cache/mailboxInfo/MailboxController.kt @@ -104,8 +104,12 @@ class MailboxController @Inject constructor( it.initLocalValues( userId = userId, quotas = localMailbox?.quotas, - inboxUnreadCount = localMailbox?.unreadCountLocal ?: 0, + inboxUnreadCount = localMailbox?.unreadCountLocal, permissions = localMailbox?.permissions, + signatures = localMailbox?.signatures, + featureFlags = localMailbox?._featureFlags, + externalMailFlagEnabled = localMailbox?.externalMailFlagEnabled, + trustedDomains = localMailbox?.trustedDomains, ) } } diff --git a/app/src/main/java/com/infomaniak/mail/data/models/mailbox/Mailbox.kt b/app/src/main/java/com/infomaniak/mail/data/models/mailbox/Mailbox.kt index 40b58a3fa8..d0b5949dd0 100644 --- a/app/src/main/java/com/infomaniak/mail/data/models/mailbox/Mailbox.kt +++ b/app/src/main/java/com/infomaniak/mail/data/models/mailbox/Mailbox.kt @@ -80,7 +80,8 @@ class Mailbox : RealmObject { @Transient var signatures = realmListOf() @Transient - private var _featureFlags = realmSetOf() + var _featureFlags = realmSetOf() + private set @Transient var externalMailFlagEnabled: Boolean = false @Transient @@ -108,12 +109,25 @@ class Mailbox : RealmObject { private fun createObjectId(userId: Int): String = "${userId}_${this.mailboxId}" - fun initLocalValues(userId: Int, quotas: Quotas?, inboxUnreadCount: Int, permissions: MailboxPermissions?) { + fun initLocalValues( + userId: Int, + quotas: Quotas?, + inboxUnreadCount: Int?, + permissions: MailboxPermissions?, + signatures: List?, + featureFlags: Set?, + externalMailFlagEnabled: Boolean?, + trustedDomains: List?, + ) { this.objectId = createObjectId(userId) this.userId = userId this.quotas = quotas - this.unreadCountLocal = inboxUnreadCount + inboxUnreadCount?.let { this.unreadCountLocal = it } this.permissions = permissions + signatures?.let(this.signatures::addAll) + featureFlags?.let(this._featureFlags::addAll) + externalMailFlagEnabled?.let { this.externalMailFlagEnabled = it } + trustedDomains?.let(this.trustedDomains::addAll) } fun getDefaultSignatureWithFallback(draftMode: DraftMode? = null): Signature {