Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Jun 20, 2024
1 parent 7f236d0 commit e19f398
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 3 additions & 6 deletions app/src/main/java/com/infomaniak/mail/utils/SentryDebug.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package com.infomaniak.mail.utils
import android.os.Bundle
import androidx.navigation.NavController
import com.infomaniak.mail.BuildConfig
import com.infomaniak.mail.data.cache.mailboxContent.DraftController
import com.infomaniak.mail.data.cache.mailboxContent.MessageController
import com.infomaniak.mail.data.cache.mailboxContent.ThreadController
import com.infomaniak.mail.data.models.Folder
Expand Down Expand Up @@ -242,13 +241,12 @@ object SentryDebug {
return orphanThreads
}

fun sendOrphanDrafts(realm: TypedRealm): RealmResults<Draft> {
val orphanDrafts = DraftController.getOrphanDrafts(realm)
if (orphanDrafts.isNotEmpty()) {
fun sendOrphanDrafts(orphans: List<Draft>) {
if (orphans.isNotEmpty()) {
Sentry.withScope { scope ->
scope.setExtra(
"orphanDrafts",
orphanDrafts.joinToString {
orphans.joinToString {
if (it.messageUid == null) {
"${Draft::localUuid.name}: [${it.localUuid}]"
} else {
Expand All @@ -259,7 +257,6 @@ object SentryDebug {
Sentry.captureMessage("We found some orphan Drafts.", SentryLevel.ERROR)
}
}
return orphanDrafts
}

fun sendOverScrolledMessage(clientWidth: Int, scrollWidth: Int, messageUid: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ class DraftsActionsWorker @AssistedInject constructor(
mailboxContentRealm.executeRealmCallbacks(realmActionsOnDraft)

mailboxContentRealm.writeBlocking {
val orphans = SentryDebug.sendOrphanDrafts(realm = this)
val orphans = DraftController.getOrphanDrafts(realm = this)
SentryDebug.sendOrphanDrafts(orphans)
delete(orphans)
}

Expand Down

0 comments on commit e19f398

Please sign in to comment.