mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-24 03:46:23 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
42 lines
1.2 KiB
Swift
42 lines
1.2 KiB
Swift
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
|
|
}
|
|
}
|