From 1066fdfa831b359fdd3df1d639cafd89ba024dbd Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Tue, 4 Mar 2025 10:41:03 +0100 Subject: [PATCH] feat: Filter snoozed threads to display with a stronger condition This mimics the behavior on the web and help avoid displaying threads that are in an incoherent state on the API --- .../mail/data/cache/mailboxContent/ThreadController.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/infomaniak/mail/data/cache/mailboxContent/ThreadController.kt b/app/src/main/java/com/infomaniak/mail/data/cache/mailboxContent/ThreadController.kt index d4592425ee..ff9ac35dbc 100644 --- a/app/src/main/java/com/infomaniak/mail/data/cache/mailboxContent/ThreadController.kt +++ b/app/src/main/java/com/infomaniak/mail/data/cache/mailboxContent/ThreadController.kt @@ -249,10 +249,18 @@ class ThreadController @Inject constructor( realm: TypedRealm, ): RealmQuery { val snoozeState = SnoozeState.Snoozed.apiValue + val collectionOperator = if (withSnooze) "ANY" else "NONE" + val nullOperator = if (withSnooze) "!=" else "==" + + val isSnoozedState = "$collectionOperator messages._snoozeState == $1" + + // TODO: Use the thread snooze state values instead of ANY/NONE on the messages + // This mimics the behavior on the web and help avoid displaying threads that are in an incoherent state on the API + val hasCorrectMetadata = "messages.snoozeEndDate $nullOperator null AND messages.snoozeAction $nullOperator null" return realm.query( - "${Thread::folderId.name} == $0 AND $collectionOperator messages._snoozeState == $1", + "${Thread::folderId.name} == $0 AND $isSnoozedState AND $hasCorrectMetadata", folderId, snoozeState, )