diff --git a/submodules/Postbox/Sources/ChatListViewState.swift b/submodules/Postbox/Sources/ChatListViewState.swift index b00082e7fe..a0ec7f2f07 100644 --- a/submodules/Postbox/Sources/ChatListViewState.swift +++ b/submodules/Postbox/Sources/ChatListViewState.swift @@ -861,7 +861,7 @@ private final class ChatListViewSpaceState { let loadedEntries = postbox.chatListTable.entries(groupId: .root, from: (allEntries[0].index.predecessor, true), to: (allEntries[allEntries.count - 1].index.successor, true), peerChatInterfaceStateTable: postbox.peerChatInterfaceStateTable, count: 1000, predicate: nil).map(mapEntry) - //assert(loadedEntries.map({ $0.index }) == allEntries.map({ $0.index })) + assert(loadedEntries.map({ $0.index }) == allEntries.map({ $0.index })) } } #endif @@ -870,8 +870,8 @@ private final class ChatListViewSpaceState { private func checkReplayEntries(postbox: Postbox) { #if DEBUG let cleanState = ChatListViewSpaceState(postbox: postbox, space: self.space, anchorIndex: self.anchorIndex, summaryComponents: self.summaryComponents, halfLimit: self.halfLimit) - //assert(self.orderedEntries.lowerOrAtAnchor.map { $0.index } == cleanState.orderedEntries.lowerOrAtAnchor.map { $0.index }) - //assert(self.orderedEntries.higherThanAnchor.map { $0.index } == cleanState.orderedEntries.higherThanAnchor.map { $0.index }) + assert(self.orderedEntries.lowerOrAtAnchor.map { $0.index } == cleanState.orderedEntries.lowerOrAtAnchor.map { $0.index }) + assert(self.orderedEntries.higherThanAnchor.map { $0.index } == cleanState.orderedEntries.higherThanAnchor.map { $0.index }) #endif } diff --git a/submodules/Postbox/Sources/Message.swift b/submodules/Postbox/Sources/Message.swift index 356c4a4163..ebcce69cd8 100644 --- a/submodules/Postbox/Sources/Message.swift +++ b/submodules/Postbox/Sources/Message.swift @@ -156,7 +156,11 @@ public struct MessageIndex: Comparable, Hashable { return lhs.id.namespace < rhs.id.namespace } - return lhs.id.id < rhs.id.id + if lhs.id.id != rhs.id.id { + return lhs.id.id < rhs.id.id + } + + return lhs.id.peerId.toInt64() < rhs.id.peerId.toInt64() } } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index e0cbc6fd9d..3de93ae6df 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -6482,7 +6482,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return } - let tooltipScreen = TooltipScreen(text: psaText, textEntities: psaEntities, icon: .info, location: .top, shouldDismissOnTouch: { point in + let tooltipScreen = TooltipScreen(text: psaText, textEntities: psaEntities, icon: .info, location: .top, displayDuration: .custom(10.0), shouldDismissOnTouch: { point in return .ignore }, openActiveTextItem: { [weak self] item, action in guard let strongSelf = self else { @@ -6492,7 +6492,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G case let .url(url, concealed): switch action { case .tap: - strongSelf.openUrl(url, concealed: false) + strongSelf.openUrl(url, concealed: concealed) case .longTap: strongSelf.controllerInteraction?.longTap(.url(url), nil) } diff --git a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift index 27604dcf12..f6c27530ca 100644 --- a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift @@ -1877,16 +1877,16 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode if let forwardInfoNode = forwardInfoSizeApply.1(bubbleContentWidth) { strongSelf.forwardInfoNode = forwardInfoNode - forwardInfoNode.openPsa = { [weak strongSelf] type, sourceNode in - guard let strongSelf = strongSelf, let item = strongSelf.item else { - return - } - item.controllerInteraction.displayPsa(type, sourceNode) - } var animateFrame = true if forwardInfoNode.supernode == nil { strongSelf.contextSourceNode.contentNode.addSubnode(forwardInfoNode) animateFrame = false + forwardInfoNode.openPsa = { [weak strongSelf] type, sourceNode in + guard let strongSelf = strongSelf, let item = strongSelf.item else { + return + } + item.controllerInteraction.displayPsa(type, sourceNode) + } } let previousForwardInfoNodeFrame = forwardInfoNode.frame forwardInfoNode.frame = CGRect(origin: CGPoint(x: contentOrigin.x + layoutConstants.text.bubbleInsets.left, y: layoutConstants.bubble.contentInsets.top + forwardInfoOriginY), size: forwardInfoSizeApply.0) diff --git a/submodules/TelegramUI/Sources/ChatMessageForwardInfoNode.swift b/submodules/TelegramUI/Sources/ChatMessageForwardInfoNode.swift index 8a36b17e1b..71cff3c186 100644 --- a/submodules/TelegramUI/Sources/ChatMessageForwardInfoNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageForwardInfoNode.swift @@ -154,7 +154,32 @@ class ChatMessageForwardInfoNode: ASDisplayNode { case .standalone: let serviceColor = serviceMessageColorComponents(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) titleColor = serviceColor.primaryText - completeSourceString = strings.Message_ForwardedMessageShort(peerString) + + if let psaType = psaType { + var customFormat: String? + let key = "Message.ForwardedPsa.\(psaType)" + if let string = presentationData.strings.primaryComponent.dict[key] { + customFormat = string + } else if let string = presentationData.strings.secondaryComponent?.dict[key] { + customFormat = string + } + + if let customFormat = customFormat { + if let range = customFormat.range(of: "%@") { + let leftPart = String(customFormat[customFormat.startIndex ..< range.lowerBound]) + let rightPart = String(customFormat[range.upperBound...]) + + let formattedText = leftPart + peerString + rightPart + completeSourceString = (formattedText, [(0, NSRange(location: leftPart.count, length: peerString.count))]) + } else { + completeSourceString = (customFormat, []) + } + } else { + completeSourceString = strings.Message_GenericForwardedPsa(peerString) + } + } else { + completeSourceString = strings.Message_ForwardedMessageShort(peerString) + } } var currentCredibilityIconImage: UIImage? diff --git a/submodules/TelegramUI/Sources/ChatMessageInstantVideoItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageInstantVideoItemNode.swift index ab61c76d3e..968f3d1d31 100644 --- a/submodules/TelegramUI/Sources/ChatMessageInstantVideoItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageInstantVideoItemNode.swift @@ -122,6 +122,10 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView { if let strongSelf = self { if let shareButtonNode = strongSelf.shareButtonNode, shareButtonNode.frame.contains(point) { return .fail + } else if let forwardInfoNode = strongSelf.forwardInfoNode, forwardInfoNode.frame.contains(point) { + if forwardInfoNode.hasAction(at: strongSelf.view.convert(point, to: forwardInfoNode.view)) { + return .fail + } } } return .waitForSingleTap @@ -572,6 +576,12 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView { if strongSelf.forwardInfoNode == nil { strongSelf.forwardInfoNode = forwardInfoNode strongSelf.addSubnode(forwardInfoNode) + forwardInfoNode.openPsa = { [weak strongSelf] type, sourceNode in + guard let strongSelf = strongSelf, let item = strongSelf.item else { + return + } + item.controllerInteraction.displayPsa(type, sourceNode) + } } let forwardInfoFrame = CGRect(origin: CGPoint(x: (!incoming ? (params.leftInset + layoutConstants.bubble.edgeInset + 12.0) : (params.width - params.rightInset - forwardInfoSize.width - layoutConstants.bubble.edgeInset - 12.0)), y: 8.0), size: forwardInfoSize) forwardInfoNode.frame = forwardInfoFrame @@ -696,26 +706,28 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView { if let forwardInfoNode = self.forwardInfoNode, forwardInfoNode.frame.contains(location) { if let item = self.item, let forwardInfo = item.message.forwardInfo { - if let sourceMessageId = forwardInfo.sourceMessageId { - if let channel = forwardInfo.author as? TelegramChannel, channel.username == nil { - if case .member = channel.participationStatus { - } else { - return .optionalAction({ + let performAction: () -> Void = { + if let sourceMessageId = forwardInfo.sourceMessageId { + if let channel = forwardInfo.author as? TelegramChannel, channel.username == nil { + if case let .broadcast(info) = channel.info, info.flags.contains(.hasDiscussionGroup) { + } else if case .member = channel.participationStatus { + } else { item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_PrivateChannelTooltip, forwardInfoNode, nil) - }) + return + } } - } - return .optionalAction({ item.controllerInteraction.navigateToMessage(item.message.id, sourceMessageId) - }) - } else if let id = forwardInfo.source?.id ?? forwardInfo.author?.id { - return .optionalAction({ - item.controllerInteraction.openPeer(id, .chat(textInputState: nil, subject: nil), nil) - }) - } else if let _ = forwardInfo.authorSignature { - return .optionalAction({ + } else if let id = forwardInfo.source?.id ?? forwardInfo.author?.id { + item.controllerInteraction.openPeer(id, .info, nil) + } else if let _ = forwardInfo.authorSignature { item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, forwardInfoNode, nil) - }) + } + } + + if forwardInfoNode.hasAction(at: self.view.convert(location, to: forwardInfoNode.view)) { + return .action({}) + } else { + return .optionalAction(performAction) } } }