mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix group reactions and tag filtering
This commit is contained in:
parent
714bcf7af3
commit
3fe8232c6e
@ -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
|
||||
|
@ -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
|
||||
))
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
))
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
))
|
||||
|
@ -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
|
||||
))
|
||||
|
@ -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
|
||||
))
|
||||
|
@ -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
|
||||
))
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
))
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 6b73742cdc140c46a1ab1b8e3390354a9738e429
|
||||
Subproject commit 564c632f9368409870631d3cef75a7fc4070d45b
|
Loading…
x
Reference in New Issue
Block a user