mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Merge groups when displaying resend message options
This commit is contained in:
parent
00c60a628c
commit
ee64afdf1a
@ -3102,7 +3102,9 @@ public final class Postbox {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if let messages = self.messageHistoryTable.getMessageFailedGroup(at: index, limit: 100) {
|
if let messages = self.messageHistoryTable.getMessageFailedGroup(at: index, limit: 100) {
|
||||||
return messages.map(self.renderIntermediateMessage)
|
return messages.sorted(by: { lhs, rhs in
|
||||||
|
return lhs.index < rhs.index
|
||||||
|
}).map(self.renderIntermediateMessage)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1430,7 +1430,38 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
let _ = (strongSelf.context.account.postbox.transaction { transaction -> [Message] in
|
let _ = (strongSelf.context.account.postbox.transaction { transaction -> [Message] in
|
||||||
return transaction.getMessageFailedGroup(id) ?? []
|
return transaction.getMessageFailedGroup(id) ?? []
|
||||||
} |> deliverOnMainQueue).start(next: { messages in
|
} |> deliverOnMainQueue).start(next: { messages in
|
||||||
guard let strongSelf = self, let message = messages.filter({ $0.id == id }).first else {
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var groups: [UInt32: [Message]] = [:]
|
||||||
|
var notGrouped: [Message] = []
|
||||||
|
for message in messages {
|
||||||
|
if let groupInfo = message.groupInfo {
|
||||||
|
if groups[groupInfo.stableId] == nil {
|
||||||
|
groups[groupInfo.stableId] = []
|
||||||
|
}
|
||||||
|
groups[groupInfo.stableId]?.append(message)
|
||||||
|
} else {
|
||||||
|
notGrouped.append(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let totalGroupCount = notGrouped.count + groups.count
|
||||||
|
|
||||||
|
var maybeSelectedGroup: [Message]?
|
||||||
|
for (_, group) in groups {
|
||||||
|
if group.contains(where: { $0.id == id}) {
|
||||||
|
maybeSelectedGroup = group
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for message in notGrouped {
|
||||||
|
if message.id == id {
|
||||||
|
maybeSelectedGroup = [message]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
guard let selectedGroup = maybeSelectedGroup, let topMessage = selectedGroup.first else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1439,12 +1470,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Resend"), color: theme.actionSheet.primaryTextColor)
|
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Resend"), color: theme.actionSheet.primaryTextColor)
|
||||||
}, action: { [weak self] _, f in
|
}, action: { [weak self] _, f in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
let _ = resendMessages(account: strongSelf.context.account, messageIds: [id]).start()
|
let _ = resendMessages(account: strongSelf.context.account, messageIds: selectedGroup.map({ $0.id })).start()
|
||||||
}
|
}
|
||||||
f(.dismissWithoutContent)
|
f(.dismissWithoutContent)
|
||||||
})))
|
})))
|
||||||
if messages.count != 1 {
|
if totalGroupCount != 1 {
|
||||||
actions.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.Conversation_MessageDialogRetryAll(messages.count).0, icon: { theme in
|
actions.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.Conversation_MessageDialogRetryAll(totalGroupCount).0, icon: { theme in
|
||||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Resend"), color: theme.actionSheet.primaryTextColor)
|
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Resend"), color: theme.actionSheet.primaryTextColor)
|
||||||
}, action: { [weak self] _, f in
|
}, action: { [weak self] _, f in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
@ -1462,7 +1493,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
f(.dismissWithoutContent)
|
f(.dismissWithoutContent)
|
||||||
})))
|
})))
|
||||||
|
|
||||||
let controller = ContextController(account: strongSelf.context.account, theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, source: .extracted(ChatMessageContextExtractedContentSource(chatNode: strongSelf.chatDisplayNode, message: message)), items: .single(actions), reactionItems: [], recognizer: nil)
|
let controller = ContextController(account: strongSelf.context.account, theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, source: .extracted(ChatMessageContextExtractedContentSource(chatNode: strongSelf.chatDisplayNode, message: topMessage)), items: .single(actions), reactionItems: [], recognizer: nil)
|
||||||
strongSelf.currentContextController = controller
|
strongSelf.currentContextController = controller
|
||||||
strongSelf.window?.presentInGlobalOverlay(controller)
|
strongSelf.window?.presentInGlobalOverlay(controller)
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user