mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Fix message ordering
This commit is contained in:
parent
95bb7b585e
commit
0574fa8ae9
@ -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
|
||||
}
|
||||
|
||||
|
@ -156,8 +156,12 @@ public struct MessageIndex: Comparable, Hashable {
|
||||
return lhs.id.namespace < rhs.id.namespace
|
||||
}
|
||||
|
||||
if lhs.id.id != rhs.id.id {
|
||||
return lhs.id.id < rhs.id.id
|
||||
}
|
||||
|
||||
return lhs.id.peerId.toInt64() < rhs.id.peerId.toInt64()
|
||||
}
|
||||
}
|
||||
|
||||
public struct ChatListIndex: Comparable, Hashable {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -1877,16 +1877,16 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode
|
||||
|
||||
if let forwardInfoNode = forwardInfoSizeApply.1(bubbleContentWidth) {
|
||||
strongSelf.forwardInfoNode = forwardInfoNode
|
||||
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)
|
||||
}
|
||||
var animateFrame = true
|
||||
if forwardInfoNode.supernode == nil {
|
||||
strongSelf.contextSourceNode.contentNode.addSubnode(forwardInfoNode)
|
||||
animateFrame = false
|
||||
}
|
||||
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)
|
||||
|
@ -154,8 +154,33 @@ class ChatMessageForwardInfoNode: ASDisplayNode {
|
||||
case .standalone:
|
||||
let serviceColor = serviceMessageColorComponents(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper)
|
||||
titleColor = serviceColor.primaryText
|
||||
|
||||
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?
|
||||
var highlight = true
|
||||
|
@ -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 {
|
||||
let performAction: () -> Void = {
|
||||
if let sourceMessageId = forwardInfo.sourceMessageId {
|
||||
if let channel = forwardInfo.author as? TelegramChannel, channel.username == nil {
|
||||
if case .member = channel.participationStatus {
|
||||
if case let .broadcast(info) = channel.info, info.flags.contains(.hasDiscussionGroup) {
|
||||
} else if case .member = channel.participationStatus {
|
||||
} else {
|
||||
return .optionalAction({
|
||||
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)
|
||||
})
|
||||
item.controllerInteraction.openPeer(id, .info, nil)
|
||||
} else if let _ = forwardInfo.authorSignature {
|
||||
return .optionalAction({
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user