mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Refactor SyncCore
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import Foundation
|
||||
#if os(macOS)
|
||||
import PostboxMac
|
||||
#else
|
||||
import Postbox
|
||||
#endif
|
||||
|
||||
public enum SynchronizeInstalledStickerPacksOperationNamespace: Int32 {
|
||||
case stickers = 0
|
||||
case masks = 1
|
||||
}
|
||||
|
||||
public final class SynchronizeInstalledStickerPacksOperation: PostboxCoding {
|
||||
public let previousPacks: [ItemCollectionId]
|
||||
public let archivedPacks: [ItemCollectionId]
|
||||
|
||||
public init(previousPacks: [ItemCollectionId], archivedPacks: [ItemCollectionId]) {
|
||||
self.previousPacks = previousPacks
|
||||
self.archivedPacks = archivedPacks
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.previousPacks = ItemCollectionId.decodeArrayFromBuffer(decoder.decodeBytesForKey("p")!)
|
||||
self.archivedPacks = decoder.decodeBytesForKey("ap").flatMap(ItemCollectionId.decodeArrayFromBuffer) ?? []
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
let buffer = WriteBuffer()
|
||||
ItemCollectionId.encodeArrayToBuffer(self.previousPacks, buffer: buffer)
|
||||
encoder.encodeBytes(buffer, forKey: "p")
|
||||
buffer.reset()
|
||||
ItemCollectionId.encodeArrayToBuffer(self.archivedPacks, buffer: buffer)
|
||||
encoder.encodeBytes(buffer, forKey: "ap")
|
||||
}
|
||||
}
|
||||
|
||||
public final class SynchronizeMarkFeaturedStickerPacksAsSeenOperation: PostboxCoding {
|
||||
public let ids: [ItemCollectionId]
|
||||
|
||||
public init(ids: [ItemCollectionId]) {
|
||||
self.ids = ids
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.ids = ItemCollectionId.decodeArrayFromBuffer(decoder.decodeBytesForKey("p")!)
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
let buffer = WriteBuffer()
|
||||
ItemCollectionId.encodeArrayToBuffer(self.ids, buffer: buffer)
|
||||
encoder.encodeBytes(buffer, forKey: "p")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user