Fix channel comment message threadIds

This commit is contained in:
Ali 2023-01-15 20:42:37 +04:00
parent 0cc27f6782
commit 4199e25314
3 changed files with 20 additions and 7 deletions

View File

@ -437,6 +437,7 @@ final class MutableMessageHistoryView {
case .external: case .external:
break break
} }
} }
func replay(postbox: PostboxImpl, transaction: PostboxTransaction) -> Bool { func replay(postbox: PostboxImpl, transaction: PostboxTransaction) -> Bool {

View File

@ -575,7 +575,17 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
if let replyToMessageId = replyToMessageId { if let replyToMessageId = replyToMessageId {
if let message = transaction.getMessage(replyToMessageId) { if let message = transaction.getMessage(replyToMessageId) {
if let threadIdValue = message.threadId { if let threadIdValue = message.threadId {
threadId = threadIdValue if threadIdValue == 1 {
if let channel = transaction.getPeer(message.id.peerId) as? TelegramChannel, channel.flags.contains(.isForum) {
threadId = threadIdValue
} else {
if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .group = channel.info {
threadId = makeMessageThreadId(replyToMessageId)
}
}
} else {
threadId = threadIdValue
}
} else if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .group = channel.info { } else if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .group = channel.info {
threadId = makeMessageThreadId(replyToMessageId) threadId = makeMessageThreadId(replyToMessageId)
} }

View File

@ -3065,13 +3065,15 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
if foundCorrelationMessage { if foundCorrelationMessage {
self.layoutActionOnViewTransition = nil self.layoutActionOnViewTransition = nil
let (mappedTransition, updateSizeAndInsets) = layoutActionOnViewTransition(transition)
self.transaction(deleteIndices: mappedTransition.deleteItems, insertIndicesAndItems: transition.insertItems, updateIndicesAndItems: transition.updateItems, options: mappedTransition.options, scrollToItem: mappedTransition.scrollToItem, updateSizeAndInsets: updateSizeAndInsets, stationaryItemRange: mappedTransition.stationaryItemRange, updateOpaqueState: ChatHistoryTransactionOpaqueState(historyView: transition.historyView), completion: { result in
completion(true, result)
})
} else {
self.transaction(deleteIndices: transition.deleteItems, insertIndicesAndItems: transition.insertItems, updateIndicesAndItems: transition.updateItems, options: transition.options, scrollToItem: transition.scrollToItem, stationaryItemRange: transition.stationaryItemRange, updateOpaqueState: ChatHistoryTransactionOpaqueState(historyView: transition.historyView), completion: { result in
completion(false, result)
})
} }
let (mappedTransition, updateSizeAndInsets) = layoutActionOnViewTransition(transition)
self.transaction(deleteIndices: mappedTransition.deleteItems, insertIndicesAndItems: transition.insertItems, updateIndicesAndItems: transition.updateItems, options: mappedTransition.options, scrollToItem: mappedTransition.scrollToItem, updateSizeAndInsets: updateSizeAndInsets, stationaryItemRange: mappedTransition.stationaryItemRange, updateOpaqueState: ChatHistoryTransactionOpaqueState(historyView: transition.historyView), completion: { result in
completion(true, result)
})
} else { } else {
self.transaction(deleteIndices: transition.deleteItems, insertIndicesAndItems: transition.insertItems, updateIndicesAndItems: transition.updateItems, options: transition.options, scrollToItem: transition.scrollToItem, stationaryItemRange: transition.stationaryItemRange, updateOpaqueState: ChatHistoryTransactionOpaqueState(historyView: transition.historyView), completion: { result in self.transaction(deleteIndices: transition.deleteItems, insertIndicesAndItems: transition.insertItems, updateIndicesAndItems: transition.updateItems, options: transition.options, scrollToItem: transition.scrollToItem, stationaryItemRange: transition.stationaryItemRange, updateOpaqueState: ChatHistoryTransactionOpaqueState(historyView: transition.historyView), completion: { result in
completion(false, result) completion(false, result)