Skip to content

Commit 121ecd2

Browse files
TommyDL-InfomaniakKevinBoulongne
authored andcommitted
Fix SonarCloud issue
1 parent 66df3b4 commit 121ecd2

File tree

3 files changed

+35
-25
lines changed

3 files changed

+35
-25
lines changed

app/src/main/java/com/infomaniak/mail/data/cache/mailboxContent/RefreshController.kt

+7-5
Original file line numberDiff line numberDiff line change
@@ -736,11 +736,13 @@ class RefreshController @Inject constructor(
736736
}
737737

738738
remoteMessage.initLocalValues(
739-
date = remoteMessage.date,
740-
isFullyDownloaded = false,
741-
isTrashed = folder.role == FolderRole.TRASH,
742-
isFromSearch = false,
743-
draftLocalUuid = null,
739+
Message.MessageInitialState(
740+
date = remoteMessage.date,
741+
isFullyDownloaded = false,
742+
isTrashed = folder.role == FolderRole.TRASH,
743+
isFromSearch = false,
744+
draftLocalUuid = null,
745+
),
744746
latestCalendarEventResponse = null,
745747
)
746748

app/src/main/java/com/infomaniak/mail/data/cache/mailboxContent/ThreadController.kt

+14-10
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ class ThreadController @Inject constructor(
9898
// The Search only returns Messages from TRASH if we explicitly selected this folder,
9999
// which is the reason why we can compute the `isTrashed` value so loosely.
100100
remoteMessage.initLocalValues(
101-
date = localMessage?.date ?: remoteMessage.date,
102-
isFullyDownloaded = localMessage?.isFullyDownloaded() ?: false,
103-
isTrashed = filterFolder?.role == FolderRole.TRASH,
104-
isFromSearch = localMessage == null,
105-
draftLocalUuid = localMessage?.draftLocalUuid,
101+
Message.MessageInitialState(
102+
date = localMessage?.date ?: remoteMessage.date,
103+
isFullyDownloaded = localMessage?.isFullyDownloaded() ?: false,
104+
isTrashed = filterFolder?.role == FolderRole.TRASH,
105+
isFromSearch = localMessage == null,
106+
draftLocalUuid = localMessage?.draftLocalUuid,
107+
),
106108
latestCalendarEventResponse = null,
107109
)
108110

@@ -313,11 +315,13 @@ class ThreadController @Inject constructor(
313315
} ?: realmListOf()
314316

315317
remoteMessage.initLocalValues(
316-
date = localMessage.date,
317-
isFullyDownloaded = true,
318-
isTrashed = localMessage.isTrashed,
319-
isFromSearch = localMessage.isFromSearch,
320-
draftLocalUuid = remoteMessage.getDraftLocalUuid(realm),
318+
Message.MessageInitialState(
319+
date = localMessage.date,
320+
isFullyDownloaded = true,
321+
isTrashed = localMessage.isTrashed,
322+
isFromSearch = localMessage.isFromSearch,
323+
draftLocalUuid = remoteMessage.getDraftLocalUuid(realm),
324+
),
321325
latestCalendarEventResponse = localMessage.latestCalendarEventResponse,
322326
messageIds = localMessage.messageIds,
323327
swissTransferFiles = swissTransferFiles

app/src/main/java/com/infomaniak/mail/data/models/message/Message.kt

+14-10
Original file line numberDiff line numberDiff line change
@@ -209,21 +209,17 @@ class Message : RealmObject {
209209
}
210210

211211
fun initLocalValues(
212-
date: RealmInstant,
213-
isFullyDownloaded: Boolean,
214-
isTrashed: Boolean,
215-
isFromSearch: Boolean,
216-
draftLocalUuid: String?,
212+
messageInitialState: MessageInitialState,
217213
latestCalendarEventResponse: CalendarEventResponse?,
218214
messageIds: RealmSet<String>? = null,
219215
swissTransferFiles: RealmList<SwissTransferFile> = realmListOf()
220216
) {
221217

222-
this.date = date
223-
this._isFullyDownloaded = isFullyDownloaded
224-
this.isTrashed = isTrashed
225-
draftLocalUuid?.let { this.draftLocalUuid = it }
226-
this.isFromSearch = isFromSearch
218+
this.date = messageInitialState.date
219+
this._isFullyDownloaded = messageInitialState.isFullyDownloaded
220+
this.isTrashed = messageInitialState.isTrashed
221+
messageInitialState.draftLocalUuid?.let { this.draftLocalUuid = it }
222+
this.isFromSearch = messageInitialState.isFromSearch
227223
this.messageIds = messageIds ?: computeMessageIds()
228224
this.latestCalendarEventResponse = latestCalendarEventResponse
229225
this.swissTransferFiles = swissTransferFiles
@@ -324,4 +320,12 @@ class Message : RealmObject {
324320
override fun equals(other: Any?) = other === this || (other is Message && other.uid == uid)
325321

326322
override fun hashCode(): Int = uid.hashCode()
323+
324+
data class MessageInitialState(
325+
val date: RealmInstant,
326+
val isFullyDownloaded: Boolean,
327+
val isTrashed: Boolean,
328+
val isFromSearch: Boolean,
329+
val draftLocalUuid: String?
330+
)
327331
}

0 commit comments

Comments
 (0)