diff --git a/submodules/Postbox/Sources/Coding.swift b/submodules/Postbox/Sources/Coding.swift index 0aaa7d87bc..9128c80edd 100644 --- a/submodules/Postbox/Sources/Coding.swift +++ b/submodules/Postbox/Sources/Coding.swift @@ -671,6 +671,20 @@ public final class PostboxEncoder { self.buffer.write(value) } + func encodeInnerObjectDataWithHeader(typeHash: Int32, data: Data, valueType: ValueType, forKey key: String) { + self.encodeKey(key) + + var t: Int8 = valueType.rawValue + self.buffer.write(&t, offset: 0, length: 1) + + var typeHash = typeHash + self.buffer.write(&typeHash, offset: 0, length: 4) + + var length: Int32 = Int32(data.count) + self.buffer.write(&length, offset: 0, length: 4) + self.buffer.write(data) + } + public let sharedWriteBuffer = WriteBuffer() } diff --git a/submodules/Postbox/Sources/Utils/Encoder/AdaptedPostboxKeyedEncodingContainer.swift b/submodules/Postbox/Sources/Utils/Encoder/AdaptedPostboxKeyedEncodingContainer.swift index cd152c85e1..8ca346d42a 100644 --- a/submodules/Postbox/Sources/Utils/Encoder/AdaptedPostboxKeyedEncodingContainer.swift +++ b/submodules/Postbox/Sources/Utils/Encoder/AdaptedPostboxKeyedEncodingContainer.swift @@ -44,12 +44,7 @@ extension _AdaptedPostboxEncoder.KeyedContainer: KeyedEncodingContainerProtocol if let value = value as? Data { self.encoder.encodeData(value, forKey: key.stringValue) } else if let value = value as? AdaptedPostboxEncoder.RawObjectData { - let typeHash: Int32 = value.typeHash - let innerEncoder = _AdaptedPostboxEncoder(typeHash: typeHash) - try! value.encode(to: innerEncoder) - - let (data, valueType) = innerEncoder.makeData(addHeader: true, isDictionary: false) - self.encoder.encodeInnerObjectData(data, valueType: valueType, forKey: key.stringValue) + self.encoder.encodeInnerObjectDataWithHeader(typeHash: value.typeHash, data: value.data, valueType: .Object, forKey: key.stringValue) } else { let typeHash: Int32 = murMurHashString32("\(type(of: value))") let innerEncoder = _AdaptedPostboxEncoder(typeHash: typeHash) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift index 713f294bb2..97f7bb021d 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift @@ -69,7 +69,7 @@ public final class ChatThemes: Codable, Equatable { func _internal_getChatThemes(accountManager: AccountManager, network: Network, forceUpdate: Bool = false, onlyCached: Bool = false) -> Signal<[ChatTheme], NoError> { let fetch: ([ChatTheme]?, Int32?) -> Signal<[ChatTheme], NoError> = { current, hash in - return network.request(Api.functions.account.getChatThemes(hash: hash ?? 0)) + return network.request(Api.functions.account.getChatThemes(hash: 0)) |> retryRequest |> mapToSignal { result -> Signal<[ChatTheme], NoError> in switch result {