From 66619d2e1789272bd2486bb7d66f79c05ce1ff15 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Fri, 10 Mar 2023 11:07:19 +0400 Subject: [PATCH] Fix attach menu buttons --- .../TelegramUI/Sources/ChatController.swift | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index e74b906937..0e42e7860b 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -12833,24 +12833,29 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G break case .gift: initialButton = .gift - case let .bot(botId, _, _): - for bot in attachMenuBots.reversed() { - var peerType = peerType - if bot.peer.id == peer.id { - peerType.insert(.sameBot) - peerType.remove(.bot) - } - let button: AttachmentButtonType = .app(bot.peer, bot.shortName, bot.icons) - if !bot.peerTypes.intersection(peerType).isEmpty { - buttons.insert(button, at: 1) - + default: + break + } + + for bot in attachMenuBots.reversed() { + var peerType = peerType + if bot.peer.id == peer.id { + peerType.insert(.sameBot) + peerType.remove(.bot) + } + let button: AttachmentButtonType = .app(bot.peer, bot.shortName, bot.icons) + if !bot.peerTypes.intersection(peerType).isEmpty { + buttons.insert(button, at: 1) + + if case let .bot(botId, _, _) = subject { if initialButton == nil && bot.peer.id == botId { initialButton = button } } - allButtons.insert(button, at: 1) } + allButtons.insert(button, at: 1) } + return (buttons, allButtons, initialButton) } } else {