diff --git a/submodules/Postbox/Sources/MessageHistoryViewState.swift b/submodules/Postbox/Sources/MessageHistoryViewState.swift index 172f9b1e76..04cb937f96 100644 --- a/submodules/Postbox/Sources/MessageHistoryViewState.swift +++ b/submodules/Postbox/Sources/MessageHistoryViewState.swift @@ -55,8 +55,6 @@ private extension MessageHistoryInput { } } - var items = postbox.messageHistoryTable.fetch(peerId: peerId, namespace: namespace, tag: tag, customTag: customTag, threadId: threadId, from: fromIndex, includeFrom: includeFrom, to: toIndex, ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange, limit: limit) - var shouldAddFromSameGroup = false if let tagInfo { switch tagInfo { @@ -66,6 +64,9 @@ private extension MessageHistoryInput { shouldAddFromSameGroup = true } } + + var items = postbox.messageHistoryTable.fetch(peerId: peerId, namespace: namespace, tag: tag, customTag: customTag, threadId: threadId, from: fromIndex, includeFrom: includeFrom || shouldAddFromSameGroup, to: toIndex, ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange, limit: limit) + if shouldAddFromSameGroup { enum Direction { case lowToHigh @@ -88,7 +89,7 @@ private extension MessageHistoryInput { case .highToLow: group = group.filter { item in if includeFrom { - return item.index >= toIndex && item.index < fromIndex + return item.index > toIndex && item.index <= fromIndex } else { return item.index > toIndex && item.index < fromIndex } @@ -127,10 +128,24 @@ private extension MessageHistoryInput { for i in 0 ..< items.count { processItem(index: i, direction: .lowToHigh) } + items = items.filter { item in + if includeFrom { + return item.index >= fromIndex && item.index < toIndex + } else { + return item.index > fromIndex && item.index < toIndex + } + } } else { for i in (0 ..< items.count).reversed() { processItem(index: i, direction: .highToLow) } + items = items.filter { item in + if includeFrom { + return item.index > toIndex && item.index <= fromIndex + } else { + return item.index > toIndex && item.index < fromIndex + } + } } } return items diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/Sources/ChatMessageContactBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/Sources/ChatMessageContactBubbleContentNode.swift index 8ad44104cf..ff61a4319a 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/Sources/ChatMessageContactBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/Sources/ChatMessageContactBubbleContentNode.swift @@ -59,7 +59,7 @@ public class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode { guard let strongSelf = self, let item = strongSelf.item else { return } - item.controllerInteraction.updateMessageReaction(item.message, .reaction(value), false, sourceView) + item.controllerInteraction.updateMessageReaction(item.topMessage, .reaction(value), false, sourceView) } self.dateAndStatusNode.openReactionPreview = { [weak self] gesture, sourceView, value in @@ -290,11 +290,11 @@ public class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - areReactionsTags: item.message.areReactionsTags(accountPeerId: item.context.account.peerId), + areReactionsTags: item.topMessage.areReactionsTags(accountPeerId: item.context.account.peerId), replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.message, isInline: item.associatedData.isInline), + canViewReactionList: canViewMessageReactionList(message: item.topMessage, isInline: item.associatedData.isInline), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageFileBubbleContentNode/Sources/ChatMessageFileBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageFileBubbleContentNode/Sources/ChatMessageFileBubbleContentNode.swift index b89448e015..10d7db9283 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageFileBubbleContentNode/Sources/ChatMessageFileBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageFileBubbleContentNode/Sources/ChatMessageFileBubbleContentNode.swift @@ -68,7 +68,7 @@ public class ChatMessageFileBubbleContentNode: ChatMessageBubbleContentNode { guard let strongSelf = self, let item = strongSelf.item else { return } - item.controllerInteraction.updateMessageReaction(item.message, .reaction(value), false, sourceView) + item.controllerInteraction.updateMessageReaction(item.topMessage, .reaction(value), false, sourceView) } self.interactiveFileNode.dateAndStatusNode.openReactionPreview = { [weak self] gesture, sourceNode, value in diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift index 51fa4fc306..039e6f062f 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift @@ -134,7 +134,7 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode, guard let strongSelf = self, let item = strongSelf.item else { return } - item.controllerInteraction.updateMessageReaction(item.message, .reaction(value), false, sourceView) + item.controllerInteraction.updateMessageReaction(item.topMessage, .reaction(value), false, sourceView) } self.dateAndStatusNode.openReactionPreview = { [weak self] gesture, sourceView, value in @@ -526,11 +526,11 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode, reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - areReactionsTags: item.message.areReactionsTags(accountPeerId: item.context.account.peerId), + areReactionsTags: item.topMessage.areReactionsTags(accountPeerId: item.context.account.peerId), replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.message, isInline: item.associatedData.isInline), + canViewReactionList: canViewMessageReactionList(message: item.topMessage, isInline: item.associatedData.isInline), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInstantVideoBubbleContentNode/Sources/ChatMessageInstantVideoBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInstantVideoBubbleContentNode/Sources/ChatMessageInstantVideoBubbleContentNode.swift index ec55612699..9eee510b6d 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInstantVideoBubbleContentNode/Sources/ChatMessageInstantVideoBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInstantVideoBubbleContentNode/Sources/ChatMessageInstantVideoBubbleContentNode.swift @@ -148,7 +148,7 @@ public class ChatMessageInstantVideoBubbleContentNode: ChatMessageBubbleContentN guard let strongSelf = self, let item = strongSelf.item else { return } - item.controllerInteraction.updateMessageReaction(item.message, .reaction(value), false, sourceView) + item.controllerInteraction.updateMessageReaction(item.topMessage, .reaction(value), false, sourceView) } self.interactiveFileNode.dateAndStatusNode.openReactionPreview = { [weak self] gesture, sourceNode, value in diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift index b48bb3b249..7a91ff58a3 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift @@ -942,7 +942,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode { replyCount: dateReplies, isPinned: arguments.isPinned && !arguments.associatedData.isInPinnedListMode, hasAutoremove: arguments.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: arguments.message, isInline: arguments.associatedData.isInline), + canViewReactionList: canViewMessageReactionList(message: arguments.topMessage, isInline: arguments.associatedData.isInline), animationCache: arguments.controllerInteraction.presentationContext.animationCache, animationRenderer: arguments.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift index ce30016614..3266ebbd36 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift @@ -578,11 +578,11 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - areReactionsTags: item.message.areReactionsTags(accountPeerId: item.context.account.peerId), + areReactionsTags: item.topMessage.areReactionsTags(accountPeerId: item.context.account.peerId), replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.message, isInline: item.associatedData.isInline), + canViewReactionList: canViewMessageReactionList(message: item.topMessage, isInline: item.associatedData.isInline), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageMapBubbleContentNode/Sources/ChatMessageMapBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageMapBubbleContentNode/Sources/ChatMessageMapBubbleContentNode.swift index 221e58614a..18cf176515 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageMapBubbleContentNode/Sources/ChatMessageMapBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageMapBubbleContentNode/Sources/ChatMessageMapBubbleContentNode.swift @@ -277,11 +277,11 @@ public class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - areReactionsTags: item.message.areReactionsTags(accountPeerId: item.context.account.peerId), + areReactionsTags: item.topMessage.areReactionsTags(accountPeerId: item.context.account.peerId), replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.message, isInline: item.associatedData.isInline), + canViewReactionList: canViewMessageReactionList(message: item.topMessage, isInline: item.associatedData.isInline), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift index 3334f09eca..a0261a4de6 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift @@ -1025,11 +1025,11 @@ public class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - areReactionsTags: item.message.areReactionsTags(accountPeerId: item.context.account.peerId), + areReactionsTags: item.topMessage.areReactionsTags(accountPeerId: item.context.account.peerId), replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.message, isInline: item.associatedData.isInline), + canViewReactionList: canViewMessageReactionList(message: item.topMessage, isInline: item.associatedData.isInline), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift index 6f80be5787..bc1f7ca0a1 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift @@ -490,7 +490,7 @@ public final class ChatMessageReactionsFooterContentNode: ChatMessageBubbleConte guard let strongSelf = self, let item = strongSelf.item else { return } - item.controllerInteraction.updateMessageReaction(item.message, .reaction(value), false, sourceView) + item.controllerInteraction.updateMessageReaction(item.topMessage, .reaction(value), false, sourceView) } self.buttonsNode.openReactionPreview = { [weak self] gesture, sourceNode, value in diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageRestrictedBubbleContentNode/Sources/ChatMessageRestrictedBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageRestrictedBubbleContentNode/Sources/ChatMessageRestrictedBubbleContentNode.swift index d8610b77de..6dbf1521f6 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageRestrictedBubbleContentNode/Sources/ChatMessageRestrictedBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageRestrictedBubbleContentNode/Sources/ChatMessageRestrictedBubbleContentNode.swift @@ -133,11 +133,11 @@ public class ChatMessageRestrictedBubbleContentNode: ChatMessageBubbleContentNod reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - areReactionsTags: item.message.areReactionsTags(accountPeerId: item.context.account.peerId), + areReactionsTags: item.topMessage.areReactionsTags(accountPeerId: item.context.account.peerId), replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.message, isInline: item.associatedData.isInline), + canViewReactionList: canViewMessageReactionList(message: item.topMessage, isInline: item.associatedData.isInline), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift index d6b5cf4088..d4e364efe4 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift @@ -574,11 +574,11 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - areReactionsTags: item.message.areReactionsTags(accountPeerId: item.context.account.peerId), + areReactionsTags: item.topMessage.areReactionsTags(accountPeerId: item.context.account.peerId), replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && (!item.associatedData.isInPinnedListMode || isReplyThread), hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.message, isInline: item.associatedData.isInline), + canViewReactionList: canViewMessageReactionList(message: item.topMessage, isInline: item.associatedData.isInline), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) @@ -719,7 +719,7 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode { guard let strongSelf, let item = strongSelf.item else { return } - item.controllerInteraction.updateMessageReaction(item.message, .reaction(value), false, sourceView) + item.controllerInteraction.updateMessageReaction(item.topMessage, .reaction(value), false, sourceView) } statusNode.openReactionPreview = { [weak strongSelf] gesture, sourceNode, value in guard let strongSelf, let item = strongSelf.item else { diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index b97818a131..6300e95a9d 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -1279,6 +1279,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let self else { return } + self.openMessageReactionContextMenu(message: message, sourceView: sourceView, gesture: gesture, value: value) }, updateMessageReaction: { [weak self] initialMessage, reaction, force, sourceView in guard let strongSelf = self else { diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index 6b73742cdc..564c632f93 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit 6b73742cdc140c46a1ab1b8e3390354a9738e429 +Subproject commit 564c632f9368409870631d3cef75a7fc4070d45b