mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-06 20:54:04 +00:00
Merge branches 'master' and 'master' of https://github.com/peter-iakovlev/TelegramCore
This commit is contained in:
commit
8c4bf2783d
@ -51,6 +51,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[690781161] = { return Api.PageBlock.parse_pageBlockEmbedPost($0) }
|
||||
dict[145955919] = { return Api.PageBlock.parse_pageBlockCollage($0) }
|
||||
dict[319588707] = { return Api.PageBlock.parse_pageBlockSlideshow($0) }
|
||||
dict[-283684427] = { return Api.PageBlock.parse_pageBlockChannel($0) }
|
||||
dict[-614138572] = { return Api.account.TmpPassword.parse_tmpPassword($0) }
|
||||
dict[590459437] = { return Api.Photo.parse_photoEmpty($0) }
|
||||
dict[-1836524247] = { return Api.Photo.parse_photo($0) }
|
||||
@ -2825,6 +2826,7 @@ public struct Api {
|
||||
case pageBlockEmbedPost(url: String, webpageId: Int64, authorPhotoId: Int64, author: String, date: Int32, blocks: [Api.PageBlock], caption: Api.RichText)
|
||||
case pageBlockCollage(items: [Api.PageBlock], caption: Api.RichText)
|
||||
case pageBlockSlideshow(items: [Api.PageBlock], caption: Api.RichText)
|
||||
case pageBlockChannel(channel: Api.Chat)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) -> Swift.Bool {
|
||||
switch self {
|
||||
@ -2992,6 +2994,12 @@ public struct Api {
|
||||
}
|
||||
caption.serialize(buffer, true)
|
||||
break
|
||||
case .pageBlockChannel(let channel):
|
||||
if boxed {
|
||||
buffer.appendInt32(-283684427)
|
||||
}
|
||||
channel.serialize(buffer, true)
|
||||
break
|
||||
}
|
||||
return true
|
||||
}
|
||||
@ -3325,6 +3333,19 @@ public struct Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
fileprivate static func parse_pageBlockChannel(_ reader: BufferReader) -> PageBlock? {
|
||||
var _1: Api.Chat?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.Chat
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.PageBlock.pageBlockChannel(channel: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
get {
|
||||
@ -3371,6 +3392,8 @@ public struct Api {
|
||||
return "(pageBlockCollage items: \(items), caption: \(caption))"
|
||||
case .pageBlockSlideshow(let items, let caption):
|
||||
return "(pageBlockSlideshow items: \(items), caption: \(caption))"
|
||||
case .pageBlockChannel(let channel):
|
||||
return "(pageBlockChannel channel: \(channel))"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ private enum InstantPageBlockType: Int32 {
|
||||
case postEmbed = 18
|
||||
case collage = 19
|
||||
case slideshow = 20
|
||||
case channelBanner = 21
|
||||
}
|
||||
|
||||
public indirect enum InstantPageBlock: Coding, Equatable {
|
||||
@ -51,6 +52,7 @@ public indirect enum InstantPageBlock: Coding, Equatable {
|
||||
case postEmbed(url: String, webpageId: MediaId?, avatarId: MediaId?, author: String, date: Int32, blocks: [InstantPageBlock], caption: RichText)
|
||||
case collage(items: [InstantPageBlock], caption: RichText)
|
||||
case slideshow(items: [InstantPageBlock], caption: RichText)
|
||||
case channelBanner(TelegramChannel?)
|
||||
|
||||
public init(decoder: Decoder) {
|
||||
switch decoder.decodeInt32ForKey("r") as Int32 {
|
||||
@ -102,6 +104,8 @@ public indirect enum InstantPageBlock: Coding, Equatable {
|
||||
self = .collage(items: decoder.decodeObjectArrayWithDecoderForKey("b"), caption: decoder.decodeObjectForKey("c", decoder: { RichText(decoder: $0) }) as! RichText)
|
||||
case InstantPageBlockType.slideshow.rawValue:
|
||||
self = .slideshow(items: decoder.decodeObjectArrayWithDecoderForKey("b"), caption: decoder.decodeObjectForKey("c", decoder: { RichText(decoder: $0) }) as! RichText)
|
||||
case InstantPageBlockType.channelBanner.rawValue:
|
||||
self = .channelBanner(decoder.decodeObjectForKey("c") as? TelegramChannel)
|
||||
default:
|
||||
self = .unsupported
|
||||
}
|
||||
@ -214,6 +218,13 @@ public indirect enum InstantPageBlock: Coding, Equatable {
|
||||
encoder.encodeInt32(InstantPageBlockType.slideshow.rawValue, forKey: "r")
|
||||
encoder.encodeObjectArray(items, forKey: "b")
|
||||
encoder.encodeObject(caption, forKey: "c")
|
||||
case let .channelBanner(channel):
|
||||
encoder.encodeInt32(InstantPageBlockType.channelBanner.rawValue, forKey: "r")
|
||||
if let channel = channel {
|
||||
encoder.encodeObject(channel, forKey: "c")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "c")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,7 +356,20 @@ public indirect enum InstantPageBlock: Coding, Equatable {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
case let .channelBanner(lhsChannel):
|
||||
if case let .channelBanner(rhsChannel) = rhs {
|
||||
if let lhsChannel = lhsChannel, let rhsChannel = rhsChannel {
|
||||
if !lhsChannel.isEqual(rhsChannel) {
|
||||
return false
|
||||
}
|
||||
} else if (lhsChannel != nil) != (rhsChannel != nil) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -469,13 +493,15 @@ extension InstantPageBlock {
|
||||
case let .pageBlockCover(cover):
|
||||
self = .cover(InstantPageBlock(apiBlock: cover))
|
||||
case let .pageBlockEmbed(flags, url, html, posterPhotoId, w, h, caption):
|
||||
self = .webEmbed(url: url, html: html, dimensions: CGSize(width: CGFloat(w ?? 0), height: CGFloat(h ?? 0)), caption: RichText(apiText: caption), stretchToWidth: (flags & (1 << 0)) != 0, allowScrolling: (flags & (1 << 3)) != 0)
|
||||
self = .webEmbed(url: url, html: html, dimensions: CGSize(width: CGFloat(w), height: CGFloat(h)), caption: RichText(apiText: caption), stretchToWidth: (flags & (1 << 0)) != 0, allowScrolling: (flags & (1 << 3)) != 0)
|
||||
case let .pageBlockEmbedPost(url, webpageId, authorPhotoId, author, date, blocks, caption):
|
||||
self = .postEmbed(url: url, webpageId: webpageId == 0 ? nil : MediaId(namespace: Namespaces.Media.CloudWebpage, id: webpageId), avatarId: authorPhotoId == 0 ? nil : MediaId(namespace: Namespaces.Media.CloudImage, id: authorPhotoId), author: author, date: date, blocks: blocks.map({ InstantPageBlock(apiBlock: $0) }), caption: RichText(apiText: caption))
|
||||
case let .pageBlockCollage(items, caption):
|
||||
self = .collage(items: items.map({ InstantPageBlock(apiBlock: $0) }), caption: RichText(apiText: caption))
|
||||
case let .pageBlockSlideshow(items, caption):
|
||||
self = .slideshow(items: items.map({ InstantPageBlock(apiBlock: $0) }), caption: RichText(apiText: caption))
|
||||
case let .pageBlockChannel(channel: apiChat):
|
||||
self = .channelBanner(parseTelegramGroupOrChannel(chat: apiChat) as? TelegramChannel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user