diff --git a/TelegramUI/AuthorizationSequenceSplashController.swift b/TelegramUI/AuthorizationSequenceSplashController.swift index be85c08cf4..cb63a6a075 100644 --- a/TelegramUI/AuthorizationSequenceSplashController.swift +++ b/TelegramUI/AuthorizationSequenceSplashController.swift @@ -96,7 +96,7 @@ final class AuthorizationSequenceSplashController: ViewController { } private func addControllerIfNeeded() { - if !controller.isViewLoaded { + if !controller.isViewLoaded || controller.view.superview == nil { self.displayNode.view.addSubview(controller.view) controller.view.frame = self.displayNode.bounds; controller.viewDidAppear(false) diff --git a/TelegramUI/ChatMessageInteractiveMediaNode.swift b/TelegramUI/ChatMessageInteractiveMediaNode.swift index e9ced341b6..10620e2ebf 100644 --- a/TelegramUI/ChatMessageInteractiveMediaNode.swift +++ b/TelegramUI/ChatMessageInteractiveMediaNode.swift @@ -526,9 +526,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode { progressRequired = true } } - case .Remote: - progressRequired = true - case .Fetching: + case .Remote, .Fetching: if let _ = webpage, let automaticDownload = self.automaticDownload, automaticDownload { progressRequired = false } else { diff --git a/TelegramUI/ChatMessageReplyInfoNode.swift b/TelegramUI/ChatMessageReplyInfoNode.swift index 088c8532aa..81044b0706 100644 --- a/TelegramUI/ChatMessageReplyInfoNode.swift +++ b/TelegramUI/ChatMessageReplyInfoNode.swift @@ -138,10 +138,12 @@ class ChatMessageReplyInfoNode: ASDisplayNode { let contrainedTextSize = CGSize(width: maximumTextWidth, height: constrainedSize.height) - let (titleLayout, titleApply) = titleNodeLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: titleString, font: titleFont, textColor: titleColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: contrainedTextSize, alignment: .natural, cutout: nil, insets: UIEdgeInsets())) - let (textLayout, textApply) = textNodeLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: textString, font: textFont, textColor: textColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: contrainedTextSize, alignment: .natural, cutout: nil, insets: UIEdgeInsets())) + let textInsets = UIEdgeInsets(top: 3.0, left: 0.0, bottom: 3.0, right: 0.0) - let size = CGSize(width: max(titleLayout.size.width, textLayout.size.width) + leftInset, height: titleLayout.size.height + textLayout.size.height + 2 * spacing) + let (titleLayout, titleApply) = titleNodeLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: titleString, font: titleFont, textColor: titleColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: contrainedTextSize, alignment: .natural, cutout: nil, insets: textInsets)) + let (textLayout, textApply) = textNodeLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: textString, font: textFont, textColor: textColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: contrainedTextSize, alignment: .natural, cutout: nil, insets: textInsets)) + + let size = CGSize(width: max(titleLayout.size.width - textInsets.left - textInsets.right, textLayout.size.width - textInsets.left - textInsets.right) + leftInset, height: titleLayout.size.height + textLayout.size.height - 2 * (textInsets.top + textInsets.bottom) + 2 * spacing) return (size, { let node: ChatMessageReplyInfoNode @@ -185,8 +187,8 @@ class ChatMessageReplyInfoNode: ASDisplayNode { node.imageNode = nil } - titleNode.frame = CGRect(origin: CGPoint(x: leftInset, y: spacing), size: titleLayout.size) - textNode.frame = CGRect(origin: CGPoint(x: leftInset, y: titleNode.frame.maxY + spacing), size: textLayout.size) + titleNode.frame = CGRect(origin: CGPoint(x: leftInset - textInsets.left, y: spacing - textInsets.top), size: titleLayout.size) + textNode.frame = CGRect(origin: CGPoint(x: leftInset - textInsets.left, y: titleNode.frame.maxY - textInsets.bottom + spacing - textInsets.top), size: textLayout.size) node.lineNode.image = lineImage node.lineNode.frame = CGRect(origin: CGPoint(x: 1.0, y: 3.0), size: CGSize(width: 2.0, height: max(0.0, size.height - 5.0))) diff --git a/TelegramUI/OpenUrl.swift b/TelegramUI/OpenUrl.swift index 0a912d5ac4..b1d2d59538 100644 --- a/TelegramUI/OpenUrl.swift +++ b/TelegramUI/OpenUrl.swift @@ -91,6 +91,16 @@ public func parseConfirmationCodeUrl(_ url: URL) -> Int? { return code } } + if url.scheme == "tg" { + if let host = url.host, let query = url.query, let parsedUrl = parseInternalUrl(query: host + "?" + query) { + switch parsedUrl { + case let .confirmationCode(code): + return code + default: + break + } + } + } return nil } diff --git a/TelegramUI/UniversalVideoGalleryItem.swift b/TelegramUI/UniversalVideoGalleryItem.swift index 1085f6c2ce..3448905123 100644 --- a/TelegramUI/UniversalVideoGalleryItem.swift +++ b/TelegramUI/UniversalVideoGalleryItem.swift @@ -333,9 +333,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { } if let file = file { let status = messageMediaFileStatus(account: item.account, messageId: message.id, file: file) - if isWebpage { - self.scrubberView.setFetchStatusSignal(nil, strings: self.strings, fileSize: file.size) - } else { + if !isWebpage { self.scrubberView.setFetchStatusSignal(status, strings: self.strings, fileSize: file.size) } diff --git a/TelegramUI/UrlHandling.swift b/TelegramUI/UrlHandling.swift index df8d21e3a0..0b9d5a7e40 100644 --- a/TelegramUI/UrlHandling.swift +++ b/TelegramUI/UrlHandling.swift @@ -4,13 +4,13 @@ import Postbox import TelegramCore import MtProtoKitDynamic -private enum ParsedInternalPeerUrlParameter { +enum ParsedInternalPeerUrlParameter { case botStart(String) case groupBotStart(String) case channelMessage(Int32) } -private enum ParsedInternalUrl { +enum ParsedInternalUrl { case peerName(String, ParsedInternalPeerUrlParameter?) case stickerPack(String) case join(String) @@ -39,7 +39,7 @@ enum ResolvedUrl { case confirmationCode(Int) } -private func parseInternalUrl(query: String) -> ParsedInternalUrl? { +func parseInternalUrl(query: String) -> ParsedInternalUrl? { if let components = URLComponents(string: "/" + query) { var pathComponents = components.path.components(separatedBy: "/") if !pathComponents.isEmpty { @@ -91,6 +91,18 @@ private func parseInternalUrl(query: String) -> ParsedInternalUrl? { if let _ = url { return .internalInstantView(url: "https://t.me/\(query)") } + } else if peerName == "login" { + var code: String? + for queryItem in queryItems { + if let value = queryItem.value { + if queryItem.name == "code" { + code = value + } + } + } + if let code = code, let codeValue = Int(code) { + return .confirmationCode(codeValue) + } } else { for queryItem in queryItems { if let value = queryItem.value {