From 9643d1712b054fedbc41fdfc562258fd9c474146 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Thu, 23 Nov 2023 19:20:10 +0400 Subject: [PATCH] Update API --- submodules/TelegramApi/Sources/Api0.swift | 4 +-- submodules/TelegramApi/Sources/Api16.swift | 28 +++++++++++-------- submodules/TelegramApi/Sources/Api26.swift | 16 +++++------ .../Sources/ApiUtils/ApiGroupOrChannel.swift | 4 +-- .../Sources/ApiUtils/TelegramUser.swift | 8 +++--- .../Sources/PeerInfoCoverComponent.swift | 12 +++++--- 6 files changed, 40 insertions(+), 32 deletions(-) diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index 963610a591..a3cdda8b8f 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -636,7 +636,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[918946202] = { return Api.Peer.parse_peerChat($0) } dict[1498486562] = { return Api.Peer.parse_peerUser($0) } dict[-386039788] = { return Api.PeerBlocked.parse_peerBlocked($0) } - dict[-1171816122] = { return Api.PeerColor.parse_peerColor($0) } + dict[-1253352753] = { return Api.PeerColor.parse_peerColor($0) } dict[-901375139] = { return Api.PeerLocated.parse_peerLocated($0) } dict[-118740917] = { return Api.PeerLocated.parse_peerSelfLocated($0) } dict[-1721619444] = { return Api.PeerNotifySettings.parse_peerNotifySettings($0) } @@ -1084,7 +1084,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1600596305] = { return Api.help.PassportConfig.parse_passportConfig($0) } dict[-1078332329] = { return Api.help.PassportConfig.parse_passportConfigNotModified($0) } dict[324785199] = { return Api.help.PeerColorOption.parse_peerColorOption($0) } - dict[864391742] = { return Api.help.PeerColorSet.parse_peerColorProfileSet($0) } + dict[1987928555] = { return Api.help.PeerColorSet.parse_peerColorProfileSet($0) } dict[639736408] = { return Api.help.PeerColorSet.parse_peerColorSet($0) } dict[16313608] = { return Api.help.PeerColors.parse_peerColors($0) } dict[732034510] = { return Api.help.PeerColors.parse_peerColorsNotModified($0) } diff --git a/submodules/TelegramApi/Sources/Api16.swift b/submodules/TelegramApi/Sources/Api16.swift index a7f39ded9e..258955a62f 100644 --- a/submodules/TelegramApi/Sources/Api16.swift +++ b/submodules/TelegramApi/Sources/Api16.swift @@ -688,36 +688,40 @@ public extension Api { } public extension Api { enum PeerColor: TypeConstructorDescription { - case peerColor(color: Int32, backgroundEmojiId: Int64) + case peerColor(flags: Int32, color: Int32?, backgroundEmojiId: Int64?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .peerColor(let color, let backgroundEmojiId): + case .peerColor(let flags, let color, let backgroundEmojiId): if boxed { - buffer.appendInt32(-1171816122) + buffer.appendInt32(-1253352753) } - serializeInt32(color, buffer: buffer, boxed: false) - serializeInt64(backgroundEmojiId, buffer: buffer, boxed: false) + serializeInt32(flags, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 0) != 0 {serializeInt32(color!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 1) != 0 {serializeInt64(backgroundEmojiId!, buffer: buffer, boxed: false)} break } } public func descriptionFields() -> (String, [(String, Any)]) { switch self { - case .peerColor(let color, let backgroundEmojiId): - return ("peerColor", [("color", color as Any), ("backgroundEmojiId", backgroundEmojiId as Any)]) + case .peerColor(let flags, let color, let backgroundEmojiId): + return ("peerColor", [("flags", flags as Any), ("color", color as Any), ("backgroundEmojiId", backgroundEmojiId as Any)]) } } public static func parse_peerColor(_ reader: BufferReader) -> PeerColor? { var _1: Int32? _1 = reader.readInt32() - var _2: Int64? - _2 = reader.readInt64() + var _2: Int32? + if Int(_1!) & Int(1 << 0) != 0 {_2 = reader.readInt32() } + var _3: Int64? + if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt64() } let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.PeerColor.peerColor(color: _1!, backgroundEmojiId: _2!) + let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil + let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil + if _c1 && _c2 && _c3 { + return Api.PeerColor.peerColor(flags: _1!, color: _2, backgroundEmojiId: _3) } else { return nil diff --git a/submodules/TelegramApi/Sources/Api26.swift b/submodules/TelegramApi/Sources/Api26.swift index 325ebb469e..585befa4ad 100644 --- a/submodules/TelegramApi/Sources/Api26.swift +++ b/submodules/TelegramApi/Sources/Api26.swift @@ -1156,18 +1156,18 @@ public extension Api.help { } public extension Api.help { enum PeerColorSet: TypeConstructorDescription { - case peerColorProfileSet(palleteColors: [Int32], bgColors: [Int32], storyColors: [Int32]) + case peerColorProfileSet(paletteColors: [Int32], bgColors: [Int32], storyColors: [Int32]) case peerColorSet(colors: [Int32]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .peerColorProfileSet(let palleteColors, let bgColors, let storyColors): + case .peerColorProfileSet(let paletteColors, let bgColors, let storyColors): if boxed { - buffer.appendInt32(864391742) + buffer.appendInt32(1987928555) } buffer.appendInt32(481674261) - buffer.appendInt32(Int32(palleteColors.count)) - for item in palleteColors { + buffer.appendInt32(Int32(paletteColors.count)) + for item in paletteColors { serializeInt32(item, buffer: buffer, boxed: false) } buffer.appendInt32(481674261) @@ -1196,8 +1196,8 @@ public extension Api.help { public func descriptionFields() -> (String, [(String, Any)]) { switch self { - case .peerColorProfileSet(let palleteColors, let bgColors, let storyColors): - return ("peerColorProfileSet", [("palleteColors", palleteColors as Any), ("bgColors", bgColors as Any), ("storyColors", storyColors as Any)]) + case .peerColorProfileSet(let paletteColors, let bgColors, let storyColors): + return ("peerColorProfileSet", [("paletteColors", paletteColors as Any), ("bgColors", bgColors as Any), ("storyColors", storyColors as Any)]) case .peerColorSet(let colors): return ("peerColorSet", [("colors", colors as Any)]) } @@ -1220,7 +1220,7 @@ public extension Api.help { let _c2 = _2 != nil let _c3 = _3 != nil if _c1 && _c2 && _c3 { - return Api.help.PeerColorSet.peerColorProfileSet(palleteColors: _1!, bgColors: _2!, storyColors: _3!) + return Api.help.PeerColorSet.peerColorProfileSet(paletteColors: _1!, bgColors: _2!, storyColors: _3!) } else { return nil diff --git a/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift b/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift index f1fd06fb30..09181a7096 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift @@ -157,7 +157,7 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? { var backgroundEmojiId: Int64? if let color = color { switch color { - case let .peerColor(color, backgroundEmojiIdValue): + case let .peerColor(_, color, backgroundEmojiIdValue): nameColor = color backgroundEmojiId = backgroundEmojiIdValue } @@ -226,7 +226,7 @@ func mergeGroupOrChannel(lhs: Peer?, rhs: Api.Chat) -> Peer? { var backgroundEmojiId: Int64? if let color = color { switch color { - case let .peerColor(color, backgroundEmojiIdValue): + case let .peerColor(_, color, backgroundEmojiIdValue): nameColorIndex = color backgroundEmojiId = backgroundEmojiIdValue } diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramUser.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramUser.swift index abf5448344..b14c969788 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramUser.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramUser.swift @@ -100,7 +100,7 @@ extension TelegramUser { var backgroundEmojiId: Int64? if let color = color { switch color { - case let .peerColor(color, backgroundEmojiIdValue): + case let .peerColor(_, color, backgroundEmojiIdValue): nameColorIndex = color backgroundEmojiId = backgroundEmojiIdValue } @@ -110,7 +110,7 @@ extension TelegramUser { var profileBackgroundEmojiId: Int64? if let profileColor = profileColor { switch profileColor { - case let .peerColor(color, backgroundEmojiIdValue): + case let .peerColor(_, color, backgroundEmojiIdValue): profileColorIndex = color profileBackgroundEmojiId = backgroundEmojiIdValue } @@ -204,7 +204,7 @@ extension TelegramUser { var backgroundEmojiId: Int64? if let nameColor = nameColor { switch nameColor { - case let .peerColor(color, backgroundEmojiIdValue): + case let .peerColor(_, color, backgroundEmojiIdValue): nameColorIndex = color backgroundEmojiId = backgroundEmojiIdValue } @@ -214,7 +214,7 @@ extension TelegramUser { var profileBackgroundEmojiId: Int64? if let profileColor = profileColor { switch profileColor { - case let .peerColor(color, backgroundEmojiIdValue): + case let .peerColor(_, color, backgroundEmojiIdValue): profileColorIndex = color profileBackgroundEmojiId = backgroundEmojiIdValue } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoCoverComponent/Sources/PeerInfoCoverComponent.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoCoverComponent/Sources/PeerInfoCoverComponent.swift index 4b31a712c3..d9e92c5de7 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoCoverComponent/Sources/PeerInfoCoverComponent.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoCoverComponent/Sources/PeerInfoCoverComponent.swift @@ -315,8 +315,9 @@ public final class PeerInfoCoverComponent: Component { var avatarBackgroundPatternLayerCount = 0 let lokiRng = LokiRng(seed0: 123, seed1: 0, seed2: 0) - for row in 0 ..< 4 { - let avatarPatternCount = row % 2 == 0 ? 9 : 9 + let numRows = 5 + for row in 0 ..< numRows { + let avatarPatternCount: Int = 7 let avatarPatternAngleSpan: CGFloat = CGFloat.pi * 2.0 / CGFloat(avatarPatternCount - 1) for i in 0 ..< avatarPatternCount - 1 { @@ -326,13 +327,16 @@ public final class PeerInfoCoverComponent: Component { let itemScaleFraction = patternScaleValueAt(fraction: component.avatarTransitionFraction, t: itemDistanceFraction, reverse: false) let itemDistance = baseItemDistance * (1.0 - itemScaleFraction) + 20.0 * itemScaleFraction - var itemAngle = -CGFloat.pi * 0.5 + CGFloat(i) * avatarPatternAngleSpan + var itemAngle: CGFloat + itemAngle = -CGFloat.pi * 0.5 + CGFloat(i) * avatarPatternAngleSpan if row % 2 != 0 { itemAngle += avatarPatternAngleSpan * 0.5 } let itemPosition = CGPoint(x: cos(itemAngle) * itemDistance, y: sin(itemAngle) * itemDistance) - let itemScale: CGFloat = 0.7 + CGFloat(lokiRng.next()) * (1.0 - 0.7) + var itemScale: CGFloat + itemScale = 0.7 + CGFloat(lokiRng.next()) * (1.0 - 0.7) + let itemSize: CGFloat = floor(26.0 * itemScale) let itemFrame = CGSize(width: itemSize, height: itemSize).centered(around: itemPosition)