From 81b68449c78a0839efc6410c69b0cb72cc25f668 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Sun, 1 Jan 2023 20:01:46 +0400 Subject: [PATCH 1/2] Remove debugging --- submodules/TelegramVoip/Sources/OngoingCallContext.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/submodules/TelegramVoip/Sources/OngoingCallContext.swift b/submodules/TelegramVoip/Sources/OngoingCallContext.swift index 15ff1892e0..67f3f2dfdf 100644 --- a/submodules/TelegramVoip/Sources/OngoingCallContext.swift +++ b/submodules/TelegramVoip/Sources/OngoingCallContext.swift @@ -79,11 +79,11 @@ private func callConnectionDescriptionsWebrtc(_ connection: CallSessionConnectio guard let id = idMapping[reflector.id] else { return [] } - #if DEBUG + /*#if DEBUG if id != 1 { return [] } - #endif + #endif*/ var result: [OngoingCallConnectionDescriptionWebrtc] = [] if !reflector.ip.isEmpty { result.append(OngoingCallConnectionDescriptionWebrtc(reflectorId: id, hasStun: false, hasTurn: true, hasTcp: reflector.isTcp, ip: reflector.ip, port: reflector.port, username: "reflector", password: hexString(reflector.peerTag))) @@ -93,11 +93,11 @@ private func callConnectionDescriptionsWebrtc(_ connection: CallSessionConnectio } return result case let .webRtcReflector(reflector): - #if DEBUG + /*#if DEBUG if "".isEmpty { return [] } - #endif + #endif*/ var result: [OngoingCallConnectionDescriptionWebrtc] = [] if !reflector.ip.isEmpty { result.append(OngoingCallConnectionDescriptionWebrtc(reflectorId: 0, hasStun: reflector.hasStun, hasTurn: reflector.hasTurn, hasTcp: false, ip: reflector.ip, port: reflector.port, username: reflector.username, password: reflector.password)) From a526ba7843812706c9b341eba7caf227d8f01b29 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Mon, 2 Jan 2023 16:52:15 +0400 Subject: [PATCH 2/2] Add fallback for the emoji template pack --- .../Sources/ReactionImageComponent.swift | 8 +- .../SyncCore/SyncCore_TelegramMediaFile.swift | 20 +++ .../Sources/EmojiStatusComponent.swift | 8 +- .../EmojiStatusSelectionComponent.swift | 8 +- .../Sources/EmojiTextAttachmentView.swift | 22 +-- .../Sources/EmojiPagerContentComponent.swift | 155 ++++++------------ 6 files changed, 83 insertions(+), 138 deletions(-) diff --git a/submodules/Components/ReactionImageComponent/Sources/ReactionImageComponent.swift b/submodules/Components/ReactionImageComponent/Sources/ReactionImageComponent.swift index 5f4efc9730..c32f0af3c8 100644 --- a/submodules/Components/ReactionImageComponent/Sources/ReactionImageComponent.swift +++ b/submodules/Components/ReactionImageComponent/Sources/ReactionImageComponent.swift @@ -31,12 +31,8 @@ public func reactionStaticImage(context: AccountContext, animation: TelegramMedi } var customColor: UIColor? - for attribute in animation.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - customColor = nil - } - } + if animation.isCustomTemplateEmoji { + customColor = nil } let fetchFrame = animationCacheFetchFile(context: context, userLocation: .other, userContentType: .sticker, resource: MediaResourceReference.standalone(resource: animation.resource), type: type, keyframeOnly: true, customColor: customColor) diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaFile.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaFile.swift index 3f831c4da7..62615e5fe1 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaFile.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaFile.swift @@ -651,6 +651,26 @@ public final class TelegramMediaFile: Media, Equatable, Codable { return hasSticker } + public var isCustomTemplateEmoji: Bool { + for attribute in self.attributes { + if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute, let packReference = packReference { + if isSingleColor { + return true + } + switch packReference { + case let .id(id, _): + if id == 1269403972611866647 { + return true + } + default: + break + } + break + } + } + return false + } + public var isPremiumEmoji: Bool { for attribute in self.attributes { if case let .CustomEmoji(isPremium, _, _, _) = attribute { diff --git a/submodules/TelegramUI/Components/EmojiStatusComponent/Sources/EmojiStatusComponent.swift b/submodules/TelegramUI/Components/EmojiStatusComponent/Sources/EmojiStatusComponent.swift index 64b86c15f3..97b2dcc296 100644 --- a/submodules/TelegramUI/Components/EmojiStatusComponent/Sources/EmojiStatusComponent.swift +++ b/submodules/TelegramUI/Components/EmojiStatusComponent/Sources/EmojiStatusComponent.swift @@ -442,11 +442,11 @@ public final class EmojiStatusComponent: Component { var accentTint = false if let _ = emojiThemeColor { + if emojiFile.isCustomTemplateEmoji { + accentTint = true + } for attribute in emojiFile.attributes { - if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute { - if isSingleColor { - accentTint = true - } + if case let .CustomEmoji(_, _, _, packReference) = attribute { switch packReference { case let .id(id, _): if id == 773947703670341676 || id == 2964141614563343 { diff --git a/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusSelectionComponent.swift b/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusSelectionComponent.swift index 0917647e6b..44fc6f1def 100644 --- a/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusSelectionComponent.swift +++ b/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusSelectionComponent.swift @@ -651,11 +651,11 @@ public final class EmojiStatusSelectionController: ViewController { effectView = view } else if let itemFile = item.itemFile { var useCleanEffect = false + if itemFile.isCustomTemplateEmoji { + useCleanEffect = true + } for attribute in itemFile.attributes { - if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute { - if isSingleColor { - useCleanEffect = true - } + if case let .CustomEmoji(_, _, _, packReference) = attribute { switch packReference { case let .id(id, _): if id == 773947703670341676 || id == 2964141614563343 { diff --git a/submodules/TelegramUI/Components/EmojiTextAttachmentView/Sources/EmojiTextAttachmentView.swift b/submodules/TelegramUI/Components/EmojiTextAttachmentView/Sources/EmojiTextAttachmentView.swift index 3676f520a0..7bc9b645cd 100644 --- a/submodules/TelegramUI/Components/EmojiTextAttachmentView/Sources/EmojiTextAttachmentView.swift +++ b/submodules/TelegramUI/Components/EmojiTextAttachmentView/Sources/EmojiTextAttachmentView.swift @@ -253,12 +253,8 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget { if !self.isDisplayingPlaceholder { var customColor = self.contentTintColor if let file = self.file { - for attribute in file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - customColor = self.dynamicColor - } - } + if file.isCustomTemplateEmoji { + customColor = self.dynamicColor } } @@ -334,12 +330,7 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget { self.loadAnimation() } else { - var isTemplate = false - for attribute in file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - isTemplate = isSingleColor - } - } + let isTemplate = file.isCustomTemplateEmoji let pointSize = self.pointSize let placeholderColor = self.placeholderColor @@ -380,12 +371,7 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget { return } - var isTemplate = false - for attribute in file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - isTemplate = isSingleColor - } - } + let isTemplate = file.isCustomTemplateEmoji let context = self.context if file.isAnimatedSticker || file.isVideoEmoji { diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift index 2e5710d15e..979ed7d5fc 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift @@ -243,12 +243,7 @@ public final class EntityKeyboardAnimationData: Equatable { } else { type = .still } - var isTemplate = false - for attribute in file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - isTemplate = isSingleColor - } - } + let isTemplate = file.isCustomTemplateEmoji self.init(id: .file(file.fileId), type: type, resource: .standalone(resource: file.resource), dimensions: file.dimensions?.cgSize ?? CGSize(width: 512.0, height: 512.0), immediateThumbnailData: file.immediateThumbnailData, isReaction: isReaction, isTemplate: isTemplate) } @@ -6442,11 +6437,11 @@ public final class EmojiPagerContentComponent: Component { existingIds.insert(file.fileId) var tintMode: Item.TintMode = .none + if file.isCustomTemplateEmoji { + tintMode = .accent + } for attribute in file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute { - if isSingleColor { - tintMode = .accent - } + if case let .CustomEmoji(_, _, _, packReference) = attribute { switch packReference { case let .id(id, _): if id == 773947703670341676 || id == 2964141614563343 { @@ -6501,11 +6496,11 @@ public final class EmojiPagerContentComponent: Component { existingIds.insert(file.fileId) var tintMode: Item.TintMode = .none + if file.isCustomTemplateEmoji { + tintMode = .accent + } for attribute in file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute { - if isSingleColor { - tintMode = .accent - } + if case let .CustomEmoji(_, _, _, packReference) = attribute { switch packReference { case let .id(id, _): if id == 773947703670341676 || id == 2964141614563343 { @@ -6547,11 +6542,11 @@ public final class EmojiPagerContentComponent: Component { existingIds.insert(file.fileId) var tintMode: Item.TintMode = .none + if file.isCustomTemplateEmoji { + tintMode = .accent + } for attribute in file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute { - if isSingleColor { - tintMode = .accent - } + if case let .CustomEmoji(_, _, _, packReference) = attribute { switch packReference { case let .id(id, _): if id == 773947703670341676 || id == 2964141614563343 { @@ -6599,11 +6594,11 @@ public final class EmojiPagerContentComponent: Component { let resultItem: EmojiPagerContentComponent.Item var tintMode: Item.TintMode = .none + if file.isCustomTemplateEmoji { + tintMode = .accent + } for attribute in file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute { - if isSingleColor { - tintMode = .accent - } + if case let .CustomEmoji(_, _, _, packReference) = attribute { switch packReference { case let .id(id, _): if id == 773947703670341676 || id == 2964141614563343 { @@ -6680,12 +6675,8 @@ public final class EmojiPagerContentComponent: Component { } var tintMode: Item.TintMode = .none - for attribute in reactionItem.file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - tintMode = .primary - } - } + if reactionItem.file.isCustomTemplateEmoji { + tintMode = .primary } let animationFile = reactionItem.file @@ -6744,12 +6735,8 @@ public final class EmojiPagerContentComponent: Component { } var tintMode: Item.TintMode = .none - for attribute in reactionItem.selectAnimation.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - tintMode = .primary - } - } + if reactionItem.selectAnimation.isCustomTemplateEmoji { + tintMode = .primary } let animationFile = reactionItem.selectAnimation @@ -6829,12 +6816,8 @@ public final class EmojiPagerContentComponent: Component { } var tintMode: Item.TintMode = .none - for attribute in animationFile.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - tintMode = .primary - } - } + if animationFile.isCustomTemplateEmoji { + tintMode = .primary } let animationData = EntityKeyboardAnimationData(file: animationFile, isReaction: true) @@ -6881,12 +6864,8 @@ public final class EmojiPagerContentComponent: Component { switch item.content { case let .file(file): var tintMode: Item.TintMode = .none - for attribute in file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - tintMode = .primary - } - } + if file.isCustomTemplateEmoji { + tintMode = .primary } let animationData = EntityKeyboardAnimationData(file: file) @@ -6936,15 +6915,11 @@ public final class EmojiPagerContentComponent: Component { } var tintMode: Item.TintMode = .none - for attribute in item.file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - if isStatusSelection { - tintMode = .accent - } else { - tintMode = .primary - } - } + if item.file.isCustomTemplateEmoji { + if isStatusSelection { + tintMode = .accent + } else { + tintMode = .primary } } @@ -7011,15 +6986,11 @@ public final class EmojiPagerContentComponent: Component { for item in featuredEmojiPack.topItems { var tintMode: Item.TintMode = .none - for attribute in item.file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - if isStatusSelection { - tintMode = .accent - } else { - tintMode = .primary - } - } + if item.file.isCustomTemplateEmoji { + if isStatusSelection { + tintMode = .accent + } else { + tintMode = .primary } } @@ -7307,12 +7278,8 @@ public final class EmojiPagerContentComponent: Component { } var tintMode: Item.TintMode = .none - for attribute in item.file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - tintMode = .primary - } - } + if item.file.isCustomTemplateEmoji { + tintMode = .primary } let resultItem = EmojiPagerContentComponent.Item( @@ -7353,12 +7320,8 @@ public final class EmojiPagerContentComponent: Component { } var tintMode: Item.TintMode = .none - for attribute in item.file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - tintMode = .primary - } - } + if item.file.isCustomTemplateEmoji { + tintMode = .primary } let animationData = EntityKeyboardAnimationData(file: item.file) @@ -7391,12 +7354,8 @@ public final class EmojiPagerContentComponent: Component { } var tintMode: Item.TintMode = .none - for attribute in item.media.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - tintMode = .primary - } - } + if item.media.isCustomTemplateEmoji { + tintMode = .primary } let animationData = EntityKeyboardAnimationData(file: item.media) @@ -7452,12 +7411,8 @@ public final class EmojiPagerContentComponent: Component { processedIds.insert(item.file.fileId) var tintMode: Item.TintMode = .none - for attribute in item.file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - tintMode = .primary - } - } + if item.file.isCustomTemplateEmoji { + tintMode = .primary } let animationData = EntityKeyboardAnimationData(file: item.file) @@ -7495,12 +7450,8 @@ public final class EmojiPagerContentComponent: Component { processedIds.insert(item.file.fileId) var tintMode: Item.TintMode = .none - for attribute in item.file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - tintMode = .primary - } - } + if item.file.isCustomTemplateEmoji { + tintMode = .primary } let animationData = EntityKeyboardAnimationData(file: item.file) @@ -7529,12 +7480,8 @@ public final class EmojiPagerContentComponent: Component { } var tintMode: Item.TintMode = .none - for attribute in item.file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - tintMode = .primary - } - } + if item.file.isCustomTemplateEmoji { + tintMode = .primary } let animationData = EntityKeyboardAnimationData(file: item.file) @@ -7593,12 +7540,8 @@ public final class EmojiPagerContentComponent: Component { for item in featuredStickerPack.topItems { var tintMode: Item.TintMode = .none - for attribute in item.file.attributes { - if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { - if isSingleColor { - tintMode = .primary - } - } + if item.file.isCustomTemplateEmoji { + tintMode = .primary } let animationData = EntityKeyboardAnimationData(file: item.file)