mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-02-22 02:23:16 +00:00
Updates TelegramCore to work with --struct-count=360. This batch includes story types, update types, user types, theme types, and various other constructors in the 340-359 type range. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
44 lines
2.0 KiB
Swift
44 lines
2.0 KiB
Swift
import Foundation
|
|
import Postbox
|
|
import TelegramApi
|
|
|
|
|
|
struct ChannelUpdate {
|
|
let update: Api.Update
|
|
let ptsRange: (Int32, Int32)?
|
|
}
|
|
|
|
func channelUpdatesByPeerId(updates: [ChannelUpdate]) -> [PeerId: [ChannelUpdate]] {
|
|
var grouped: [PeerId: [ChannelUpdate]] = [:]
|
|
|
|
for update in updates {
|
|
var peerId: PeerId?
|
|
switch update.update {
|
|
case let .updateNewChannelMessage(updateNewChannelMessageData):
|
|
let (message, _, _) = (updateNewChannelMessageData.message, updateNewChannelMessageData.pts, updateNewChannelMessageData.ptsCount)
|
|
peerId = apiMessagePeerId(message)
|
|
case let .updateDeleteChannelMessages(updateDeleteChannelMessagesData):
|
|
let (channelId, _, _, _) = (updateDeleteChannelMessagesData.channelId, updateDeleteChannelMessagesData.messages, updateDeleteChannelMessagesData.pts, updateDeleteChannelMessagesData.ptsCount)
|
|
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
|
case let .updateEditChannelMessage(updateEditChannelMessageData):
|
|
let (message, _, _) = (updateEditChannelMessageData.message, updateEditChannelMessageData.pts, updateEditChannelMessageData.ptsCount)
|
|
peerId = apiMessagePeerId(message)
|
|
case let .updateChannelWebPage(updateChannelWebPageData):
|
|
let (channelId, _, _, _) = (updateChannelWebPageData.channelId, updateChannelWebPageData.webpage, updateChannelWebPageData.pts, updateChannelWebPageData.ptsCount)
|
|
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
|
default:
|
|
break
|
|
}
|
|
|
|
if let peerId = peerId {
|
|
if grouped[peerId] == nil {
|
|
grouped[peerId] = [update]
|
|
} else {
|
|
grouped[peerId]!.append(update)
|
|
}
|
|
}
|
|
}
|
|
|
|
return grouped
|
|
}
|