mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Coding fixes
This commit is contained in:
parent
40736ca677
commit
e6308196fe
@ -671,6 +671,20 @@ public final class PostboxEncoder {
|
|||||||
self.buffer.write(value)
|
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()
|
public let sharedWriteBuffer = WriteBuffer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,12 +44,7 @@ extension _AdaptedPostboxEncoder.KeyedContainer: KeyedEncodingContainerProtocol
|
|||||||
if let value = value as? Data {
|
if let value = value as? Data {
|
||||||
self.encoder.encodeData(value, forKey: key.stringValue)
|
self.encoder.encodeData(value, forKey: key.stringValue)
|
||||||
} else if let value = value as? AdaptedPostboxEncoder.RawObjectData {
|
} else if let value = value as? AdaptedPostboxEncoder.RawObjectData {
|
||||||
let typeHash: Int32 = value.typeHash
|
self.encoder.encodeInnerObjectDataWithHeader(typeHash: value.typeHash, data: value.data, valueType: .Object, forKey: key.stringValue)
|
||||||
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)
|
|
||||||
} else {
|
} else {
|
||||||
let typeHash: Int32 = murMurHashString32("\(type(of: value))")
|
let typeHash: Int32 = murMurHashString32("\(type(of: value))")
|
||||||
let innerEncoder = _AdaptedPostboxEncoder(typeHash: typeHash)
|
let innerEncoder = _AdaptedPostboxEncoder(typeHash: typeHash)
|
||||||
|
@ -69,7 +69,7 @@ public final class ChatThemes: Codable, Equatable {
|
|||||||
|
|
||||||
func _internal_getChatThemes(accountManager: AccountManager<TelegramAccountManagerTypes>, network: Network, forceUpdate: Bool = false, onlyCached: Bool = false) -> Signal<[ChatTheme], NoError> {
|
func _internal_getChatThemes(accountManager: AccountManager<TelegramAccountManagerTypes>, network: Network, forceUpdate: Bool = false, onlyCached: Bool = false) -> Signal<[ChatTheme], NoError> {
|
||||||
let fetch: ([ChatTheme]?, Int32?) -> Signal<[ChatTheme], NoError> = { current, hash in
|
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
|
|> retryRequest
|
||||||
|> mapToSignal { result -> Signal<[ChatTheme], NoError> in
|
|> mapToSignal { result -> Signal<[ChatTheme], NoError> in
|
||||||
switch result {
|
switch result {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user