Skip to content

Commit

Permalink
fix: Also take into account duplicates when computing the snooze stat…
Browse files Browse the repository at this point in the history
…es of a Thread
  • Loading branch information
LunarX authored and KevinBoulongne committed Mar 6, 2025
1 parent dec7380 commit 615a8bb
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app/src/main/java/com/infomaniak/mail/data/models/thread/Thread.kt
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ class Thread : RealmObject {

private fun updateThread() {

fun Thread.updateSnoozeSatesBasedOn(message: Message) {
message.snoozeState?.let {
_snoozeState = it.apiValue
snoozeEndDate = message.snoozeEndDate
snoozeAction = message.snoozeAction
}
}

messages.sortBy { it.date }

messages.forEach { message ->
Expand All @@ -222,11 +230,11 @@ class Thread : RealmObject {
if (message.hasAttachable) hasAttachable = true
if (message.isScheduledDraft) numberOfScheduledDrafts++

message.snoozeState?.let {
_snoozeState = it.apiValue
snoozeEndDate = message.snoozeEndDate
snoozeAction = message.snoozeAction
}
updateSnoozeSatesBasedOn(message)
}

duplicates.forEach { duplicate ->
updateSnoozeSatesBasedOn(duplicate)
}

date = messages.last { it.folderId == folderId }.date
Expand Down

0 comments on commit 615a8bb

Please sign in to comment.