Created
January 19, 2024 09:51
-
-
Save Kylmakalle/d68475a89547390e26e9d83187a10d21 to your computer and use it in GitHub Desktop.
Fix SwitchInlineQuery for Telegram mini apps opened with InlineKeyboardButton https://bugs.telegram.org/c/36392 , Fix available in https://t.me/swiftgram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git forkSrcPrefix/submodules/TelegramUI/Sources/ChatController.swift forkDstPrefix/submodules/TelegramUI/Sources/ChatController.swift | |
index 73da2bf8b4cca4dbd5c7d36555019fa1afa1b777..188f83c41e67039b791b77de26469c4a27f2a911 100644 | |
--- forkSrcPrefix/submodules/TelegramUI/Sources/ChatController.swift | |
+++ forkDstPrefix/submodules/TelegramUI/Sources/ChatController.swift | |
@@ -3962,6 +3962,22 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G | |
let params = WebAppParameters(source: .generic, peerId: peerId, botId: peerId, botName: botName, url: result.url, queryId: result.queryId, payload: nil, buttonText: buttonText, keepAliveSignal: result.keepAliveSignal, forceHasSettings: false) | |
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url, concealed, commit in | |
self?.openUrl(url, concealed: concealed, forceExternal: true, commit: commit) | |
+ }, requestSwitchInline: { [weak self] query, chatTypes, completion in | |
+ if let strongSelf = self { | |
+ if let chatTypes { | |
+ let controller = strongSelf.context.sharedContext.makePeerSelectionController(PeerSelectionControllerParams(context: strongSelf.context, filter: [.excludeRecent, .doNotSearchMessages], requestPeerType: chatTypes, hasContactSelector: false, hasCreation: false)) | |
+ controller.peerSelected = { [weak self, weak controller] peer, _ in | |
+ if let strongSelf = self { | |
+ completion() | |
+ controller?.dismiss() | |
+ strongSelf.controllerInteraction?.activateSwitchInline(peer.id, "@\(botAddress) \(query)", nil) | |
+ } | |
+ } | |
+ strongSelf.push(controller) | |
+ } else { | |
+ strongSelf.controllerInteraction?.activateSwitchInline(peerId, "@\(botAddress) \(query)", nil) | |
+ } | |
+ } | |
}, completion: { [weak self] in | |
self?.chatDisplayNode.historyNode.scrollToEndOfHistory() | |
}, getNavigationController: { [weak self] in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment