Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
@@ -0,0 +1,41 @@
import Foundation
final class UnsentMessageHistoryView {
var ids: Set<MessageId>
init(ids: [MessageId]) {
self.ids = Set(ids)
}
func refreshDueToExternalTransaction(fetchUnsentMessageIds: () -> [MessageId]) -> Bool {
let ids = Set(fetchUnsentMessageIds())
postboxLog("UnsentMessageHistoryView: refreshDueToExternalTransaction: \(ids)")
if ids != self.ids {
self.ids = ids
return true
} else {
return false
}
}
func replay(_ operations: [IntermediateMessageHistoryUnsentOperation]) -> Bool {
var updated = false
for operation in operations {
postboxLog("UnsentMessageHistoryView: operation: \(operation)")
switch operation {
case let .Insert(id):
if !self.ids.contains(id) {
self.ids.insert(id)
updated = true
}
case let .Remove(id):
if self.ids.contains(id) {
self.ids.remove(id)
updated = true
}
}
}
return updated
}
}