From a7e31198b8329a13aded1a12fb99886d921b4a03 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 21 Apr 2022 01:48:16 +0400 Subject: [PATCH] Add web app removal confirmation --- Telegram/Telegram-iOS/en.lproj/Localizable.strings | 3 +++ submodules/WebUI/Sources/WebAppController.swift | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 1271477e23..e1523d2630 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -7439,6 +7439,9 @@ Sorry for the inconvenience."; "WebApp.MessagePreview" = "Message Preview"; "WebApp.Send" = "Send"; +"WebApp.RemoveConfirmationTitle" = "Remove Bot"; +"WebApp.RemoveConfirmationText" = "Remove **%@** from the attachment menu?"; + "Notifications.SystemTones" = "SYSTEM TONES"; "Notifications.TelegramTones" = "TELEGRAM TONES"; diff --git a/submodules/WebUI/Sources/WebAppController.swift b/submodules/WebUI/Sources/WebAppController.swift index 0c5e9b0d29..6cbefe0013 100644 --- a/submodules/WebUI/Sources/WebAppController.swift +++ b/submodules/WebUI/Sources/WebAppController.swift @@ -538,6 +538,7 @@ public final class WebAppController: ViewController, AttachmentContainable { private let context: AccountContext private let peerId: PeerId private let botId: PeerId + private let botName: String private let url: String? private let queryId: Int64? private let payload: String? @@ -559,6 +560,7 @@ public final class WebAppController: ViewController, AttachmentContainable { self.context = context self.peerId = params.peerId self.botId = params.botId + self.botName = params.botName self.url = params.url self.queryId = params.queryId self.payload = params.payload @@ -666,8 +668,13 @@ public final class WebAppController: ViewController, AttachmentContainable { f(.default) if let strongSelf = self { - let _ = context.engine.messages.removeBotFromAttachMenu(botId: strongSelf.botId).start() - strongSelf.dismiss() + let presentationData = context.sharedContext.currentPresentationData.with { $0 } + strongSelf.present(textAlertController(context: context, title: presentationData.strings.WebApp_RemoveConfirmationTitle, text: presentationData.strings.WebApp_RemoveConfirmationText(strongSelf.botName).string, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: { [weak self] in + if let strongSelf = self { + let _ = context.engine.messages.removeBotFromAttachMenu(botId: strongSelf.botId).start() + strongSelf.dismiss() + } + })], parseMarkdown: true), in: .window(.root)) } }))) }