diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/RequestStartBot.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/RequestStartBot.swift index acb0dd2963..a380663e85 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/RequestStartBot.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/RequestStartBot.swift @@ -8,22 +8,21 @@ import MtProtoKit func _internal_requestStartBot(account: Account, botPeerId: PeerId, payload: String?) -> Signal { if let payload = payload, !payload.isEmpty { return account.postbox.loadedPeerWithId(botPeerId) - |> mapToSignal { botPeer -> Signal in - if let inputUser = apiInputUser(botPeer) { - let r = account.network.request(Api.functions.messages.startBot(bot: inputUser, peer: .inputPeerEmpty, randomId: Int64.random(in: Int64.min ... Int64.max), startParam: payload)) - |> mapToSignal { result -> Signal in - account.stateManager.addUpdates(result) - return .complete() - } - |> `catch` { _ -> Signal in - return .complete() - } - return r - |> retryRequest - } else { + |> mapToSignal { botPeer -> Signal in + if let inputUser = apiInputUser(botPeer) { + return account.network.request(Api.functions.messages.startBot(bot: inputUser, peer: .inputPeerEmpty, randomId: Int64.random(in: Int64.min ... Int64.max), startParam: payload)) + |> mapToSignal { result -> Signal in + account.stateManager.addUpdates(result) return .complete() } + |> `catch` { _ -> Signal in + return .complete() + } + |> retryRequest + } else { + return .complete() } + } } else { return enqueueMessages(account: account, peerId: botPeerId, messages: [.message(text: "/start", attributes: [], inlineStickers: [:], mediaReference: nil, replyToMessageId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: [])]) |> mapToSignal { _ -> Signal in return .complete() diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index e43f4c0993..70a34293eb 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -4104,7 +4104,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return state.updatedShowWebView(true).updatedForceInputCommandsHidden(true) } - let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, fromMenu: true, isInline: false, isSimple: false) + let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, fromMenu: true, fromAttachMenu: false, isInline: false, isSimple: false) let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url in self?.openUrl(url, concealed: true, forceExternal: true) }, getInputContainerNode: { [weak self] in @@ -4159,7 +4159,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let strongSelf = self else { return } - let params = WebAppParameters(peerId: peerId, botId: botId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, fromMenu: false, isInline: isInline, isSimple: true) + let params = WebAppParameters(peerId: peerId, botId: botId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, fromMenu: false, fromAttachMenu: false, isInline: isInline, isSimple: true) let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url in self?.openUrl(url, concealed: true, forceExternal: true) }, requestSwitchInline: { [weak self] query, chatTypes, completion in @@ -4199,7 +4199,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let strongSelf = self else { return } - let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botName, url: result.url, queryId: result.queryId, payload: nil, buttonText: buttonText, keepAliveSignal: result.keepAliveSignal, fromMenu: false, isInline: false, isSimple: false) + let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botName, url: result.url, queryId: result.queryId, payload: nil, buttonText: buttonText, keepAliveSignal: result.keepAliveSignal, fromMenu: false, fromAttachMenu: false, isInline: false, isSimple: false) let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url in self?.openUrl(url, concealed: true, forceExternal: true) }, completion: { [weak self] in @@ -12722,7 +12722,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let strongSelf = self else { return } - let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botApp.title, url: url, queryId: 0, payload: payload, buttonText: "", keepAliveSignal: nil, fromMenu: false, isInline: false, isSimple: false) + let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botApp.title, url: url, queryId: 0, payload: payload, buttonText: "", keepAliveSignal: nil, fromMenu: false, fromAttachMenu: false, isInline: false, isSimple: false) let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url in self?.openUrl(url, concealed: true, forceExternal: true) }, completion: { [weak self] in @@ -13242,10 +13242,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } case let .app(bot, botName, _): var payload: String? + var fromAttachMenu = true if case let .bot(_, botPayload, _) = subject { payload = botPayload + fromAttachMenu = false } - let params = WebAppParameters(peerId: peer.id, botId: bot.id, botName: botName, url: nil, queryId: nil, payload: payload, buttonText: nil, keepAliveSignal: nil, fromMenu: false, isInline: false, isSimple: false) + let params = WebAppParameters(peerId: peer.id, botId: bot.id, botName: botName, url: nil, queryId: nil, payload: payload, buttonText: nil, keepAliveSignal: nil, fromMenu: false, fromAttachMenu: fromAttachMenu, isInline: false, isSimple: false) let replyMessageId = strongSelf.presentationInterfaceState.interfaceState.replyMessageId let controller = WebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, replyToMessageId: replyMessageId, threadId: strongSelf.chatLocation.threadId) controller.openUrl = { [weak self] url in diff --git a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift index 99ef6d2eac..b928764dfe 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift @@ -1597,8 +1597,8 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { } let keyboardAppearance = interfaceState.theme.rootController.keyboardColor.keyboardAppearance - if let textInputNode = self.textInputNode, textInputNode.keyboardAppearance != keyboardAppearance, textInputNode.isFirstResponder() { - if textInputNode.isCurrentlyEmoji() { + if let textInputNode = self.textInputNode, textInputNode.keyboardAppearance != keyboardAppearance { + if textInputNode.isFirstResponder() && textInputNode.isCurrentlyEmoji() { textInputNode.initialPrimaryLanguage = "emoji" textInputNode.resetInitialPrimaryLanguage() } @@ -2268,7 +2268,13 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { let _ = placeholderApply() - transition.updateFrame(node: contextPlaceholderNode, frame: CGRect(origin: CGPoint(x: hideOffset.x + leftInset + textFieldInsets.left + self.textInputViewInternalInsets.left, y: hideOffset.y + textFieldInsets.top + self.textInputViewInternalInsets.top + textInputViewRealInsets.top + UIScreenPixel), size: placeholderSize.size)) + let placeholderTransition: ContainedViewLayoutTransition + if placeholderSize.size.width == contextPlaceholderNode.frame.width { + placeholderTransition = transition + } else { + placeholderTransition = .immediate + } + placeholderTransition.updateFrame(node: contextPlaceholderNode, frame: CGRect(origin: CGPoint(x: hideOffset.x + leftInset + textFieldInsets.left + self.textInputViewInternalInsets.left, y: hideOffset.y + textFieldInsets.top + self.textInputViewInternalInsets.top + textInputViewRealInsets.top + UIScreenPixel), size: placeholderSize.size)) contextPlaceholderNode.alpha = audioRecordingItemsAlpha } else if let contextPlaceholderNode = self.contextPlaceholderNode { self.contextPlaceholderNode = nil diff --git a/submodules/TelegramUI/Sources/CommandMenuChatInputPanelItem.swift b/submodules/TelegramUI/Sources/CommandMenuChatInputPanelItem.swift index 49855b427a..5e03f5aa11 100644 --- a/submodules/TelegramUI/Sources/CommandMenuChatInputPanelItem.swift +++ b/submodules/TelegramUI/Sources/CommandMenuChatInputPanelItem.swift @@ -210,7 +210,7 @@ final class CommandMenuChatInputPanelItemNode: ListViewItemNode { let (textLayout, textApply) = makeTextLayout(TextNodeLayoutArguments(attributedString: textString, backgroundColor: nil, maximumNumberOfLines: 2, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - rightInset - 130.0, height: 100.0), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) - let (commandLayout, commandApply) = makeCommandLayout(TextNodeLayoutArguments(attributedString: commandString, backgroundColor: nil, maximumNumberOfLines: 2, truncationType: .end, constrainedSize: CGSize(width: 120.0, height: 100.0), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) + let (commandLayout, commandApply) = makeCommandLayout(TextNodeLayoutArguments(attributedString: commandString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - rightInset - textLayout.size.width - 16.0, height: 100.0), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) let nodeLayout = ListViewItemNodeLayout(contentSize: CGSize(width: params.width, height: max(CommandMenuChatInputPanelItemNode.itemHeight, textLayout.size.height + 14.0)), insets: UIEdgeInsets()) diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift index 4d73371cf8..31fe2ea434 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift @@ -3675,12 +3675,16 @@ final class PeerInfoHeaderNode: ASDisplayNode { } private class DynamicIslandMaskNode: ManagedAnimationNode { + var frameIndex: Int = 0 + func update(_ value: CGFloat) { let lowerBound = 0 let upperBound = 180 let frameIndex = lowerBound + Int(value * CGFloat(upperBound - lowerBound)) - - self.trackTo(item: ManagedAnimationItem(source: .local("UserAvatarMask"), frames: .range(startFrame: frameIndex, endFrame: frameIndex), duration: 0.001)) + if frameIndex != self.frameIndex { + self.frameIndex = frameIndex + self.trackTo(item: ManagedAnimationItem(source: .local("UserAvatarMask"), frames: .range(startFrame: frameIndex, endFrame: frameIndex), duration: 0.001)) + } } } @@ -3730,6 +3734,7 @@ private class DynamicIslandBlurNode: ASDisplayNode { } func update(_ value: CGFloat) { + let fadeAlpha = min(1.0, max(0.0, -0.25 + value * 1.55)) if value > 0.0 { self.prepare() self.effectView?.layer.timeOffset = max(0.0, -0.1 + value * 1.1) @@ -3739,8 +3744,7 @@ private class DynamicIslandBlurNode: ASDisplayNode { self.effectView?.layer.timeOffset = 0.0 self.effectView?.effect = nil } - - self.fadeNode.alpha = min(1.0, max(0.0, -0.25 + value * 1.55)) + self.fadeNode.alpha = fadeAlpha } override func layout() { diff --git a/submodules/TelegramUI/Sources/ShareExtensionContext.swift b/submodules/TelegramUI/Sources/ShareExtensionContext.swift index aa894524a8..53e0881675 100644 --- a/submodules/TelegramUI/Sources/ShareExtensionContext.swift +++ b/submodules/TelegramUI/Sources/ShareExtensionContext.swift @@ -667,7 +667,7 @@ public class ShareRootControllerImpl { attemptSelectionImpl?(peer) }, createNewGroup: { createNewGroupImpl?() - }, pretendPresentedInModal: true, selectForumThreads: true)) + }, pretendPresentedInModal: true, selectForumThreads: false)) controller.customDismiss = { self?.getExtensionContext()?.completeRequest(returningItems: nil, completionHandler: nil) diff --git a/submodules/WebUI/Sources/WebAppController.swift b/submodules/WebUI/Sources/WebAppController.swift index 1b29b48576..af5b0191e1 100644 --- a/submodules/WebUI/Sources/WebAppController.swift +++ b/submodules/WebUI/Sources/WebAppController.swift @@ -134,6 +134,7 @@ public struct WebAppParameters { let buttonText: String? let keepAliveSignal: Signal? let fromMenu: Bool + let fromAttachMenu: Bool let isInline: Bool let isSimple: Bool @@ -147,6 +148,7 @@ public struct WebAppParameters { buttonText: String?, keepAliveSignal: Signal?, fromMenu: Bool, + fromAttachMenu: Bool, isInline: Bool, isSimple: Bool ) { @@ -159,6 +161,7 @@ public struct WebAppParameters { self.buttonText = buttonText self.keepAliveSignal = keepAliveSignal self.fromMenu = fromMenu + self.fromAttachMenu = fromAttachMenu self.isInline = isInline self.isSimple = isSimple } @@ -656,7 +659,7 @@ public final class WebAppController: ViewController, AttachmentContainable { self.handleSendData(data: eventData) } case "web_app_setup_main_button": - if let webView = self.webView, !webView.didTouchOnce && controller.url == nil { + if let webView = self.webView, !webView.didTouchOnce && controller.url == nil && controller.fromAttachMenu { self.delayedScriptMessage = message } else if let json = json { if var isVisible = json["is_visible"] as? Bool { @@ -1058,6 +1061,7 @@ public final class WebAppController: ViewController, AttachmentContainable { private let payload: String? private let buttonText: String? private let fromMenu: Bool + private let fromAttachMenu: Bool private let isInline: Bool private let isSimple: Bool private let keepAliveSignal: Signal? @@ -1083,6 +1087,7 @@ public final class WebAppController: ViewController, AttachmentContainable { self.payload = params.payload self.buttonText = params.buttonText self.fromMenu = params.fromMenu + self.fromAttachMenu = params.fromAttachMenu self.isInline = params.isInline self.isSimple = params.isSimple self.keepAliveSignal = params.keepAliveSignal