Skip to content

Commit f913d16

Browse files
fix(MailboxManager:fetchOnePage): Do not refresh deleted threads (#1748)
2 parents a7428b7 + 9159ec1 commit f913d16

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

MailCore/Cache/MailboxManager/MailboxManager+Thread.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public extension MailboxManager {
292292

293293
writableRealm.delete(threadsToDelete)
294294

295-
let recomputedFolders = recomputeThreadsAndUnreadCount(of: threadsToUpdate, realm: writableRealm)
295+
let (_, recomputedFolders) = recomputeThreadsAndUnreadCount(of: threadsToUpdate, realm: writableRealm)
296296
foldersOfDeletedThreads.subtract(recomputedFolders)
297297
recomputeUnreadCountOfFolders(foldersOfDeletedThreads)
298298
}
@@ -421,9 +421,8 @@ public extension MailboxManager {
421421
}
422422
}
423423

424-
recomputeThreadsAndUnreadCount(of: threadsToUpdate, realm: writableRealm)
425-
426-
return threadsToUpdate
424+
let (updatedThreads, _) = recomputeThreadsAndUnreadCount(of: threadsToUpdate, realm: writableRealm)
425+
return updatedThreads
427426
}
428427

429428
/// Add the given message to existing compatible threads + Create a new thread if needed
@@ -554,7 +553,7 @@ public extension MailboxManager {
554553
}
555554

556555
@discardableResult
557-
private func recomputeThreadsAndUnreadCount(of threads: Set<Thread>, realm: Realm) -> Set<Folder> {
556+
private func recomputeThreadsAndUnreadCount(of threads: Set<Thread>, realm: Realm) -> (Set<Thread>, Set<Folder>) {
558557
var threadsToRecompute = threads
559558
let duplicatesThreads = Set(threads.flatMap { $0.duplicates.flatMap { $0.threads } })
560559
threadsToRecompute.formUnion(duplicatesThreads)
@@ -569,7 +568,7 @@ public extension MailboxManager {
569568
}
570569
}
571570

572-
return recomputeUnreadCountOfFolders(containing: recomputedThreads)
571+
return (recomputedThreads, recomputeUnreadCountOfFolders(containing: recomputedThreads))
573572
}
574573

575574
/// Refresh the unread count of the folders of the given threads

0 commit comments

Comments
 (0)