mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Refactoring
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
|
||||
import SyncCore
|
||||
|
||||
func addSynchronizeChatInputStateOperation(transaction: Transaction, peerId: PeerId) {
|
||||
var updateLocalIndex: Int32?
|
||||
let tag: PeerOperationLogTag = OperationLogTags.SynchronizeChatInputStates
|
||||
|
||||
var previousOperation: SynchronizeChatInputStateOperation?
|
||||
transaction.operationLogEnumerateEntries(peerId: peerId, tag: tag, { entry in
|
||||
updateLocalIndex = entry.tagLocalIndex
|
||||
if let operation = entry.contents as? SynchronizeChatInputStateOperation {
|
||||
previousOperation = operation
|
||||
}
|
||||
return false
|
||||
})
|
||||
var previousState: SynchronizeableChatInputState?
|
||||
if let previousOperation = previousOperation {
|
||||
previousState = previousOperation.previousState
|
||||
} else if let peerChatInterfaceState = transaction.getPeerChatInterfaceState(peerId) as? SynchronizeableChatInterfaceState {
|
||||
previousState = peerChatInterfaceState.synchronizeableInputState
|
||||
}
|
||||
let operationContents = SynchronizeChatInputStateOperation(previousState: previousState)
|
||||
if let updateLocalIndex = updateLocalIndex {
|
||||
let _ = transaction.operationLogRemoveEntry(peerId: peerId, tag: tag, tagLocalIndex: updateLocalIndex)
|
||||
}
|
||||
transaction.operationLogAddEntry(peerId: peerId, tag: tag, tagLocalIndex: .automatic, tagMergedIndex: .automatic, contents: operationContents)
|
||||
}
|
||||
Reference in New Issue
Block a user