@@ -292,7 +292,7 @@ public extension MailboxManager {
292
292
293
293
writableRealm. delete ( threadsToDelete)
294
294
295
- let recomputedFolders = recomputeThreadsAndUnreadCount ( of: threadsToUpdate, realm: writableRealm)
295
+ let ( _ , recomputedFolders) = recomputeThreadsAndUnreadCount ( of: threadsToUpdate, realm: writableRealm)
296
296
foldersOfDeletedThreads. subtract ( recomputedFolders)
297
297
recomputeUnreadCountOfFolders ( foldersOfDeletedThreads)
298
298
}
@@ -421,9 +421,8 @@ public extension MailboxManager {
421
421
}
422
422
}
423
423
424
- recomputeThreadsAndUnreadCount ( of: threadsToUpdate, realm: writableRealm)
425
-
426
- return threadsToUpdate
424
+ let ( updatedThreads, _) = recomputeThreadsAndUnreadCount ( of: threadsToUpdate, realm: writableRealm)
425
+ return updatedThreads
427
426
}
428
427
429
428
/// Add the given message to existing compatible threads + Create a new thread if needed
@@ -554,7 +553,7 @@ public extension MailboxManager {
554
553
}
555
554
556
555
@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 > ) {
558
557
var threadsToRecompute = threads
559
558
let duplicatesThreads = Set ( threads. flatMap { $0. duplicates. flatMap { $0. threads } } )
560
559
threadsToRecompute. formUnion ( duplicatesThreads)
@@ -569,7 +568,7 @@ public extension MailboxManager {
569
568
}
570
569
}
571
570
572
- return recomputeUnreadCountOfFolders ( containing: recomputedThreads)
571
+ return ( recomputedThreads , recomputeUnreadCountOfFolders ( containing: recomputedThreads) )
573
572
}
574
573
575
574
/// Refresh the unread count of the folders of the given threads
0 commit comments