Skip to content

Commit 062a219

Browse files
fix: Correctly get realm objects when trying to delete them (#2201)
2 parents ddf0f67 + ce030f6 commit 062a219

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

app/src/main/java/com/infomaniak/mail/MainApplication.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ open class MainApplication : Application(), ImageLoaderFactory, DefaultLifecycle
170170

171171
val shouldLog = mutableListOf<Boolean>()
172172

173-
// Sentry events are discarded is the app is in Debug mode
173+
// Sentry events are discarded if the app is in Debug mode
174174
val isInReleaseMode = !BuildConfig.DEBUG
175175
shouldLog.add(isInReleaseMode)
176176

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -402,15 +402,14 @@ class ThreadController @Inject constructor(
402402

403403
suspend fun deleteEmptyThreadsInFolder(folderId: String, realm: Realm) {
404404
realm.write {
405-
val emptyThreadsQuery = getEmptyThreadsInFolderQuery(folderId, realm = this)
406-
val emptyThreads = emptyThreadsQuery.find()
405+
val emptyThreads = getEmptyThreadsInFolderQuery(folderId, realm = this).find()
407406
// TODO: Find why we are sometimes displaying empty Threads, and fix it instead of just deleting them.
408407
// It's possibly because we are out of sync, and the situation will resolve by itself shortly?
409408
if (emptyThreads.isNotEmpty()) {
410409
emptyThreads.forEach {
411410
SentryDebug.sendEmptyThread(it, "No Message in a Thread when refreshing a Folder", realm = this)
412411
}
413-
delete(emptyThreadsQuery)
412+
delete(emptyThreads)
414413
}
415414
}
416415
}

0 commit comments

Comments
 (0)