mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-17 19:09:56 +00:00
40 lines
1.5 KiB
Swift
40 lines
1.5 KiB
Swift
import Foundation
|
|
#if os(macOS)
|
|
import PostboxMac
|
|
#else
|
|
import Postbox
|
|
#endif
|
|
|
|
final class SynchronizeConsumeMessageContentsOperation: Coding {
|
|
let messageIds: [MessageId]
|
|
|
|
init(messageIds: [MessageId]) {
|
|
self.messageIds = messageIds
|
|
}
|
|
|
|
init(decoder: Decoder) {
|
|
self.messageIds = MessageId.decodeArrayFromBuffer(decoder.decodeBytesForKeyNoCopy("i")!)
|
|
}
|
|
|
|
func encode(_ encoder: Encoder) {
|
|
let buffer = WriteBuffer()
|
|
MessageId.encodeArrayToBuffer(self.messageIds, buffer: buffer)
|
|
encoder.encodeBytes(buffer, forKey: "i")
|
|
}
|
|
}
|
|
|
|
func addSynchronizeConsumeMessageContentsOperation(modifier: Modifier, messageIds: [MessageId]) {
|
|
for (peerId, messageIds) in messagesIdsGroupedByPeerId(Set(messageIds)) {
|
|
var updateLocalIndex: Int32?
|
|
/*modifier.operationLogEnumerateEntries(peerId: peerId, tag: OperationLogTags.SynchronizeConsumeMessageContents, { entry in
|
|
updateLocalIndex = entry.tagLocalIndex
|
|
return false
|
|
})*/
|
|
let operationContents = SynchronizeConsumeMessageContentsOperation(messageIds: messageIds)
|
|
if let updateLocalIndex = updateLocalIndex {
|
|
let _ = modifier.operationLogRemoveEntry(peerId: peerId, tag: OperationLogTags.SynchronizeConsumeMessageContents, tagLocalIndex: updateLocalIndex)
|
|
}
|
|
modifier.operationLogAddEntry(peerId: peerId, tag: OperationLogTags.SynchronizeConsumeMessageContents, tagLocalIndex: .automatic, tagMergedIndex: .automatic, contents: operationContents)
|
|
}
|
|
}
|