Skip to content

Commit

Permalink
Delete Drafts orphans after sending the Sentry about them
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Jun 20, 2024
1 parent 7387631 commit 2c52039
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ class ThreadController @Inject constructor(

/**
* Initialize and retrieve the search Threads obtained from the API.
* - Format the remote threads to make them compatible with the existing logic.
* - Preserve old message data if it already exists locally.
* - Format the remote Threads to make them compatible with the existing logic.
* - Preserve old Messages data if it already exists locally.
* - Handle duplicates using the existing logic.
* @param remoteThreads The list of API Threads that need to be processed.
* @param filterFolder The selected Folder on which we filter the Search.
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/infomaniak/mail/utils/SentryDebug.kt
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ object SentryDebug {
return orphanThreads
}

fun sendOrphanDrafts(realm: TypedRealm) {
fun sendOrphanDrafts(realm: TypedRealm): RealmResults<Draft> {
val orphanDrafts = DraftController.getOrphanDrafts(realm)
if (orphanDrafts.isNotEmpty()) {
Sentry.withScope { scope ->
Expand All @@ -259,6 +259,7 @@ 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 @@ -197,7 +197,10 @@ class DraftsActionsWorker @AssistedInject constructor(

mailboxContentRealm.executeRealmCallbacks(realmActionsOnDraft)

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

showDraftErrorNotification(isTrackedDraftSuccess, trackedDraftErrorMessageResId, trackedDraftAction)

Expand Down

0 comments on commit 2c52039

Please sign in to comment.