Various improvements

This commit is contained in:
Isaac
2023-12-28 19:55:39 +04:00
parent 1d7bf5aa12
commit d8e5ff4f58
13 changed files with 212 additions and 25 deletions

View File

@@ -198,6 +198,7 @@ public struct OperationLogTags {
public static let SynchronizeAutosaveItems = PeerOperationLogTag(value: 23)
public static let SynchronizeViewStories = PeerOperationLogTag(value: 24)
public static let SynchronizePeerStories = PeerOperationLogTag(value: 25)
public static let SynchronizePinnedSavedChats = PeerOperationLogTag(value: 26)
}
public struct LegacyPeerSummaryCounterTags: OptionSet, Sequence, Hashable {

View File

@@ -61,3 +61,21 @@ public func addSynchronizePinnedChatsOperation(transaction: Transaction, groupId
}
transaction.operationLogAddEntry(peerId: PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt64Value(Int64(rawId))), tag: OperationLogTags.SynchronizePinnedChats, tagLocalIndex: .automatic, tagMergedIndex: .automatic, contents: operationContents)
}
public func addSynchronizePinnedSavedChatsOperation(transaction: Transaction, accountPeerId: PeerId) {
var previousItemIds = transaction.getPeerPinnedThreads(peerId: accountPeerId).map { PinnedItemId.peer(PeerId($0)) }
var updateLocalIndex: Int32?
transaction.operationLogEnumerateEntries(peerId: PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt64Value(0)), tag: OperationLogTags.SynchronizePinnedSavedChats, { entry in
updateLocalIndex = entry.tagLocalIndex
if let contents = entry.contents as? SynchronizePinnedChatsOperation {
previousItemIds = contents.previousItemIds
}
return false
})
let operationContents = SynchronizePinnedChatsOperation(previousItemIds: previousItemIds)
if let updateLocalIndex = updateLocalIndex {
let _ = transaction.operationLogRemoveEntry(peerId: PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt64Value(0)), tag: OperationLogTags.SynchronizePinnedSavedChats, tagLocalIndex: updateLocalIndex)
}
transaction.operationLogAddEntry(peerId: PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt64Value(0)), tag: OperationLogTags.SynchronizePinnedSavedChats, tagLocalIndex: .automatic, tagMergedIndex: .automatic, contents: operationContents)
}