Skip to content

Commit

Permalink
feat: Filter snoozed threads to display with a stronger condition
Browse files Browse the repository at this point in the history
This mimics the behavior on the web and help avoid displaying threads that are in an incoherent state on the API
  • Loading branch information
LunarX committed Mar 6, 2025
1 parent ae19941 commit 1066fdf
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,18 @@ class ThreadController @Inject constructor(
realm: TypedRealm,
): RealmQuery<Thread> {
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>(
"${Thread::folderId.name} == $0 AND $collectionOperator messages._snoozeState == $1",
"${Thread::folderId.name} == $0 AND $isSnoozedState AND $hasCorrectMetadata",
folderId,
snoozeState,
)
Expand Down

0 comments on commit 1066fdf

Please sign in to comment.