mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 11:23: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)
|
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
|
#endif
|
||||||
@ -870,8 +870,8 @@ private final class ChatListViewSpaceState {
|
|||||||
private func checkReplayEntries(postbox: Postbox) {
|
private func checkReplayEntries(postbox: Postbox) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
let cleanState = ChatListViewSpaceState(postbox: postbox, space: self.space, anchorIndex: self.anchorIndex, summaryComponents: self.summaryComponents, halfLimit: self.halfLimit)
|
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.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.higherThanAnchor.map { $0.index } == cleanState.orderedEntries.higherThanAnchor.map { $0.index })
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,11 @@ public struct MessageIndex: Comparable, Hashable {
|
|||||||
return lhs.id.namespace < rhs.id.namespace
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6482,7 +6482,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
return
|
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
|
return .ignore
|
||||||
}, openActiveTextItem: { [weak self] item, action in
|
}, openActiveTextItem: { [weak self] item, action in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
@ -6492,7 +6492,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
case let .url(url, concealed):
|
case let .url(url, concealed):
|
||||||
switch action {
|
switch action {
|
||||||
case .tap:
|
case .tap:
|
||||||
strongSelf.openUrl(url, concealed: false)
|
strongSelf.openUrl(url, concealed: concealed)
|
||||||
case .longTap:
|
case .longTap:
|
||||||
strongSelf.controllerInteraction?.longTap(.url(url), nil)
|
strongSelf.controllerInteraction?.longTap(.url(url), nil)
|
||||||
}
|
}
|
||||||
|
@ -1877,16 +1877,16 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode
|
|||||||
|
|
||||||
if let forwardInfoNode = forwardInfoSizeApply.1(bubbleContentWidth) {
|
if let forwardInfoNode = forwardInfoSizeApply.1(bubbleContentWidth) {
|
||||||
strongSelf.forwardInfoNode = forwardInfoNode
|
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
|
var animateFrame = true
|
||||||
if forwardInfoNode.supernode == nil {
|
if forwardInfoNode.supernode == nil {
|
||||||
strongSelf.contextSourceNode.contentNode.addSubnode(forwardInfoNode)
|
strongSelf.contextSourceNode.contentNode.addSubnode(forwardInfoNode)
|
||||||
animateFrame = false
|
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
|
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)
|
forwardInfoNode.frame = CGRect(origin: CGPoint(x: contentOrigin.x + layoutConstants.text.bubbleInsets.left, y: layoutConstants.bubble.contentInsets.top + forwardInfoOriginY), size: forwardInfoSizeApply.0)
|
||||||
|
@ -154,7 +154,32 @@ class ChatMessageForwardInfoNode: ASDisplayNode {
|
|||||||
case .standalone:
|
case .standalone:
|
||||||
let serviceColor = serviceMessageColorComponents(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper)
|
let serviceColor = serviceMessageColorComponents(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper)
|
||||||
titleColor = serviceColor.primaryText
|
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?
|
var currentCredibilityIconImage: UIImage?
|
||||||
|
@ -122,6 +122,10 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView {
|
|||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
if let shareButtonNode = strongSelf.shareButtonNode, shareButtonNode.frame.contains(point) {
|
if let shareButtonNode = strongSelf.shareButtonNode, shareButtonNode.frame.contains(point) {
|
||||||
return .fail
|
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
|
return .waitForSingleTap
|
||||||
@ -572,6 +576,12 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView {
|
|||||||
if strongSelf.forwardInfoNode == nil {
|
if strongSelf.forwardInfoNode == nil {
|
||||||
strongSelf.forwardInfoNode = forwardInfoNode
|
strongSelf.forwardInfoNode = forwardInfoNode
|
||||||
strongSelf.addSubnode(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)
|
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
|
forwardInfoNode.frame = forwardInfoFrame
|
||||||
@ -696,26 +706,28 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView {
|
|||||||
|
|
||||||
if let forwardInfoNode = self.forwardInfoNode, forwardInfoNode.frame.contains(location) {
|
if let forwardInfoNode = self.forwardInfoNode, forwardInfoNode.frame.contains(location) {
|
||||||
if let item = self.item, let forwardInfo = item.message.forwardInfo {
|
if let item = self.item, let forwardInfo = item.message.forwardInfo {
|
||||||
if let sourceMessageId = forwardInfo.sourceMessageId {
|
let performAction: () -> Void = {
|
||||||
if let channel = forwardInfo.author as? TelegramChannel, channel.username == nil {
|
if let sourceMessageId = forwardInfo.sourceMessageId {
|
||||||
if case .member = channel.participationStatus {
|
if let channel = forwardInfo.author as? TelegramChannel, channel.username == nil {
|
||||||
} else {
|
if case let .broadcast(info) = channel.info, info.flags.contains(.hasDiscussionGroup) {
|
||||||
return .optionalAction({
|
} else if case .member = channel.participationStatus {
|
||||||
|
} else {
|
||||||
item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_PrivateChannelTooltip, forwardInfoNode, nil)
|
item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_PrivateChannelTooltip, forwardInfoNode, nil)
|
||||||
})
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return .optionalAction({
|
|
||||||
item.controllerInteraction.navigateToMessage(item.message.id, sourceMessageId)
|
item.controllerInteraction.navigateToMessage(item.message.id, sourceMessageId)
|
||||||
})
|
} else if let id = forwardInfo.source?.id ?? forwardInfo.author?.id {
|
||||||
} else if let id = forwardInfo.source?.id ?? forwardInfo.author?.id {
|
item.controllerInteraction.openPeer(id, .info, nil)
|
||||||
return .optionalAction({
|
} else if let _ = forwardInfo.authorSignature {
|
||||||
item.controllerInteraction.openPeer(id, .chat(textInputState: nil, subject: nil), nil)
|
|
||||||
})
|
|
||||||
} else if let _ = forwardInfo.authorSignature {
|
|
||||||
return .optionalAction({
|
|
||||||
item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, forwardInfoNode, nil)
|
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