diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index dda4cb7325..c2bb76eed1 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -1250,28 +1250,30 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { currentSecretIconImage = PresentationResourcesChatList.secretIcon(item.presentationData.theme) } var credibilityIconOffset: CGFloat = 0.0 - if displayAsMessage { - switch item.content { - case let .peer(messages, _, _, _, _, _, _, _, _, _, _, _): - if let peer = messages.last?.author { - if peer.isScam { - currentCredibilityIconImage = PresentationResourcesChatList.scamIcon(item.presentationData.theme, type: .regular) - credibilityIconOffset = 2.0 - } else if peer.isVerified { - currentCredibilityIconImage = PresentationResourcesChatList.verifiedIcon(item.presentationData.theme) - credibilityIconOffset = 3.0 + if !isPeerGroup { + if displayAsMessage { + switch item.content { + case let .peer(messages, _, _, _, _, _, _, _, _, _, _, _): + if let peer = messages.last?.author { + if peer.isScam { + currentCredibilityIconImage = PresentationResourcesChatList.scamIcon(item.presentationData.theme, type: .regular) + credibilityIconOffset = 2.0 + } else if peer.isVerified { + currentCredibilityIconImage = PresentationResourcesChatList.verifiedIcon(item.presentationData.theme) + credibilityIconOffset = 3.0 + } } + default: + break + } + } else if case let .chat(itemPeer) = contentPeer, let peer = itemPeer.chatMainPeer { + if peer.isScam { + currentCredibilityIconImage = PresentationResourcesChatList.scamIcon(item.presentationData.theme, type: .regular) + credibilityIconOffset = 2.0 + } else if peer.isVerified { + currentCredibilityIconImage = PresentationResourcesChatList.verifiedIcon(item.presentationData.theme) + credibilityIconOffset = 3.0 } - default: - break - } - } else if case let .chat(itemPeer) = contentPeer, let peer = itemPeer.chatMainPeer { - if peer.isScam { - currentCredibilityIconImage = PresentationResourcesChatList.scamIcon(item.presentationData.theme, type: .regular) - credibilityIconOffset = 2.0 - } else if peer.isVerified { - currentCredibilityIconImage = PresentationResourcesChatList.verifiedIcon(item.presentationData.theme) - credibilityIconOffset = 3.0 } } if let currentSecretIconImage = currentSecretIconImage { diff --git a/submodules/StatisticsUI/Sources/StatsMessageItem.swift b/submodules/StatisticsUI/Sources/StatsMessageItem.swift index 0a8b31facc..84b7b43fc8 100644 --- a/submodules/StatisticsUI/Sources/StatsMessageItem.swift +++ b/submodules/StatisticsUI/Sources/StatsMessageItem.swift @@ -85,6 +85,13 @@ public class StatsMessageItemNode: ListViewItemNode, ItemListItemNode { private let highlightedBackgroundNode: ASDisplayNode private let maskNode: ASImageNode + let contextSourceNode: ContextExtractedContentContainingNode + private let containerNode: ContextControllerSourceNode + private let extractedBackgroundImageNode: ASImageNode + + private var extractedRect: CGRect? + private var nonExtractedRect: CGRect? + let contentImageNode: TransformImageNode let titleNode: TextNode let labelNode: TextNode @@ -117,6 +124,13 @@ public class StatsMessageItemNode: ListViewItemNode, ItemListItemNode { self.bottomStripeNode = ASDisplayNode() self.bottomStripeNode.isLayerBacked = true + self.contextSourceNode = ContextExtractedContentContainingNode() + self.containerNode = ContextControllerSourceNode() + + self.extractedBackgroundImageNode = ASImageNode() + self.extractedBackgroundImageNode.displaysAsynchronously = false + self.extractedBackgroundImageNode.alpha = 0.0 + self.contentImageNode = TransformImageNode() self.contentImageNode.isLayerBacked = true diff --git a/submodules/TelegramCallsUI/Sources/CallStatusBarNode.swift b/submodules/TelegramCallsUI/Sources/CallStatusBarNode.swift index 0d7daa59cb..39cce0f3b9 100644 --- a/submodules/TelegramCallsUI/Sources/CallStatusBarNode.swift +++ b/submodules/TelegramCallsUI/Sources/CallStatusBarNode.swift @@ -348,8 +348,12 @@ public class CallStatusBarNodeImpl: CallStatusBarNode { if let membersCount = membersCount { var membersPart = presentationData.strings.VoiceChat_Status_Members(membersCount) - if let startIndex = membersPart.firstIndex(of: "["), let endIndex = membersPart.firstIndex(of: "]") { - membersPart.removeSubrange(startIndex ... endIndex) + if membersPart.contains("[") && membersPart.contains("]") { + if let startIndex = membersPart.firstIndex(of: "["), let endIndex = membersPart.firstIndex(of: "]") { + membersPart.removeSubrange(startIndex ... endIndex) + } + } else { + membersPart = membersPart.trimmingCharacters(in: CharacterSet(charactersIn: "0123456789-,.")) } let rawTextAndRanges = presentationData.strings.VoiceChat_Status_MembersFormat("\(membersCount)", membersPart) diff --git a/submodules/TelegramUI/Sources/ChatMessageCommentFooterContentNode.swift b/submodules/TelegramUI/Sources/ChatMessageCommentFooterContentNode.swift index ffd067a569..5c3fec751a 100644 --- a/submodules/TelegramUI/Sources/ChatMessageCommentFooterContentNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageCommentFooterContentNode.swift @@ -148,8 +148,12 @@ final class ChatMessageCommentFooterContentNode: ChatMessageBubbleContentNode { rawAlternativeSegments = rawSegments } else if dateReplies > 0 { var commentsPart = item.presentationData.strings.Conversation_MessageViewComments(Int32(dateReplies)) - if let startIndex = commentsPart.firstIndex(of: "["), let endIndex = commentsPart.firstIndex(of: "]") { - commentsPart.removeSubrange(startIndex ... endIndex) + if commentsPart.contains("[") && commentsPart.contains("]") { + if let startIndex = commentsPart.firstIndex(of: "["), let endIndex = commentsPart.firstIndex(of: "]") { + commentsPart.removeSubrange(startIndex ... endIndex) + } + } else { + commentsPart = commentsPart.trimmingCharacters(in: CharacterSet(charactersIn: "0123456789-,. ")) } var segments: [AnimatedCountLabelNode.Segment] = [] @@ -170,7 +174,7 @@ final class ChatMessageCommentFooterContentNode: ChatMessageBubbleContentNode { } latestIndex = range.upperBound - let part = String(rawText[rawText.index(rawText.startIndex, offsetBy: lowerSegmentIndex) ..< rawText.index(rawText.startIndex, offsetBy: range.upperBound)]) + let part = String(rawText[rawText.index(rawText.startIndex, offsetBy: lowerSegmentIndex) ..< rawText.index(rawText.startIndex, offsetBy: min(rawText.count, range.upperBound))]) if index == 0 { segments.append(.number(dateReplies, NSAttributedString(string: part, font: textFont, textColor: messageTheme.accentTextColor))) } else { diff --git a/submodules/TelegramUI/Sources/ChatTitleView.swift b/submodules/TelegramUI/Sources/ChatTitleView.swift index 6a969ed90e..855285246e 100644 --- a/submodules/TelegramUI/Sources/ChatTitleView.swift +++ b/submodules/TelegramUI/Sources/ChatTitleView.swift @@ -152,8 +152,13 @@ final class ChatTitleView: UIView, NavigationBarTitleView { case .replies: commentsPart = self.strings.Conversation_TitleReplies(Int32(count)) } - if let startIndex = commentsPart.firstIndex(of: "["), let endIndex = commentsPart.firstIndex(of: "]") { - commentsPart.removeSubrange(startIndex ... endIndex) + + if commentsPart.contains("[") && commentsPart.contains("]") { + if let startIndex = commentsPart.firstIndex(of: "["), let endIndex = commentsPart.firstIndex(of: "]") { + commentsPart.removeSubrange(startIndex ... endIndex) + } + } else { + commentsPart = commentsPart.trimmingCharacters(in: CharacterSet(charactersIn: "0123456789-,.")) } let rawTextAndRanges: (String, [(Int, NSRange)]) diff --git a/submodules/TelegramUI/Sources/Pasteboard.swift b/submodules/TelegramUI/Sources/Pasteboard.swift index 648a9aa4a1..2bb136add6 100644 --- a/submodules/TelegramUI/Sources/Pasteboard.swift +++ b/submodules/TelegramUI/Sources/Pasteboard.swift @@ -36,10 +36,12 @@ private func chatInputStateString(attributedString: NSAttributedString) -> NSAtt attributedString.enumerateAttributes(in: NSRange(location: 0, length: attributedString.length), options: [], using: { attributes, range, _ in if let value = attributes[.link], let url = (value as? URL)?.absoluteString { string.addAttribute(ChatTextInputAttributes.textUrl, value: ChatTextInputTextUrlAttribute(url: url), range: range) - } - else if let value = attributes[.font], let font = value as? UIFont { + } else if let value = attributes[.font], let font = value as? UIFont { let fontName = font.fontName.lowercased() - if fontName.contains("bold") { + if fontName.contains("bolditalic") { + string.addAttribute(ChatTextInputAttributes.bold, value: true as NSNumber, range: range) + string.addAttribute(ChatTextInputAttributes.italic, value: true as NSNumber, range: range) + } else if fontName.contains("bold") { string.addAttribute(ChatTextInputAttributes.bold, value: true as NSNumber, range: range) } else if fontName.contains("italic") { string.addAttribute(ChatTextInputAttributes.italic, value: true as NSNumber, range: range) diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoData.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoData.swift index 510dee6cb2..35ce0d9876 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoData.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoData.swift @@ -974,6 +974,13 @@ func peerInfoHeaderButtons(peer: Peer?, cachedData: CachedPeerData?, isOpenedFro displayMore = false } } + var canReport = true + if channel.isVerified || channel.adminRights != nil || channel.flags.contains(.isCreator) { + canReport = false + } + if !canReport && !canViewStats && displayLeave { + displayMore = false + } if displayMore { result.append(.more) } diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 79345e9006..de5a83edb2 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -1595,6 +1595,14 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD var items: [ContextMenuItem] = [] + items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.SharedMedia_ViewInChat, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/GoToMessage"), color: theme.contextMenu.primaryColor) }, action: { c, _ in + c.dismiss(completion: { + if let strongSelf = self, let navigationController = strongSelf.controller?.navigationController as? NavigationController { + strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(strongSelf.peerId), subject: .message(id: message.id, highlight: true))) + } + }) + }))) + if let linkForCopying = linkForCopying { items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.Conversation_ContextMenuCopyLink, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Copy"), color: theme.contextMenu.primaryColor) }, action: { c, _ in c.dismiss(completion: {}) @@ -1609,13 +1617,6 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD } }) }))) - items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.SharedMedia_ViewInChat, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/GoToMessage"), color: theme.contextMenu.primaryColor) }, action: { c, _ in - c.dismiss(completion: { - if let strongSelf = self, let navigationController = strongSelf.controller?.navigationController as? NavigationController { - strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(strongSelf.peerId), subject: .message(id: message.id, highlight: true))) - } - }) - }))) if actions.options.contains(.deleteLocally) || actions.options.contains(.deleteGlobally) { let context = strongSelf.context let presentationData = strongSelf.presentationData @@ -4615,11 +4616,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD |> deliverOnMainQueue).start(next: { [weak self] activeSessionsContextAndCount in if let strongSelf = self, let activeSessionsContextAndCount = activeSessionsContextAndCount { let (activeSessionsContext, count, webSessionsContext) = activeSessionsContextAndCount - if count == 0 && settings.enableQRLogin { - strongSelf.controller?.push(AuthDataTransferSplashScreen(context: strongSelf.context, activeSessionsContext: activeSessionsContext)) - } else { - strongSelf.controller?.push(recentSessionsController(context: strongSelf.context, activeSessionsContext: activeSessionsContext, webSessionsContext: webSessionsContext, websitesOnly: false)) - } + strongSelf.controller?.push(recentSessionsController(context: strongSelf.context, activeSessionsContext: activeSessionsContext, webSessionsContext: webSessionsContext, websitesOnly: false)) } }) }