Serialize sticker pack addition

This commit is contained in:
Ali
2020-04-15 00:52:22 +04:00
parent 7f17b1b22d
commit f0c1f3ff3e
9 changed files with 376 additions and 262 deletions

View File

@@ -9,15 +9,18 @@ public enum SynchronizeInstalledStickerPacksOperationNamespace: Int32 {
public final class SynchronizeInstalledStickerPacksOperation: PostboxCoding {
public let previousPacks: [ItemCollectionId]
public let archivedPacks: [ItemCollectionId]
public let noDelay: Bool
public init(previousPacks: [ItemCollectionId], archivedPacks: [ItemCollectionId]) {
public init(previousPacks: [ItemCollectionId], archivedPacks: [ItemCollectionId], noDelay: Bool) {
self.previousPacks = previousPacks
self.archivedPacks = archivedPacks
self.noDelay = noDelay
}
public init(decoder: PostboxDecoder) {
self.previousPacks = ItemCollectionId.decodeArrayFromBuffer(decoder.decodeBytesForKey("p")!)
self.archivedPacks = decoder.decodeBytesForKey("ap").flatMap(ItemCollectionId.decodeArrayFromBuffer) ?? []
self.noDelay = decoder.decodeInt32ForKey("nd", orElse: 0) != 0
}
public func encode(_ encoder: PostboxEncoder) {
@@ -27,6 +30,7 @@ public final class SynchronizeInstalledStickerPacksOperation: PostboxCoding {
buffer.reset()
ItemCollectionId.encodeArrayToBuffer(self.archivedPacks, buffer: buffer)
encoder.encodeBytes(buffer, forKey: "ap")
encoder.encodeInt32(self.noDelay ? 1 : 0, forKey: "nd")
}
}