mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Refactor constructor use sites for types 460-479 to struct pattern
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1f4b520b1b
commit
5e4cbec07a
26 changed files with 454 additions and 100 deletions
|
|
@ -289,7 +289,27 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum BotResults: TypeConstructorDescription {
|
||||
case botResults(flags: Int32, queryId: Int64, nextOffset: String?, switchPm: Api.InlineBotSwitchPM?, switchWebview: Api.InlineBotWebView?, results: [Api.BotInlineResult], cacheTime: Int32, users: [Api.User])
|
||||
public class Cons_botResults {
|
||||
public var flags: Int32
|
||||
public var queryId: Int64
|
||||
public var nextOffset: String?
|
||||
public var switchPm: Api.InlineBotSwitchPM?
|
||||
public var switchWebview: Api.InlineBotWebView?
|
||||
public var results: [Api.BotInlineResult]
|
||||
public var cacheTime: Int32
|
||||
public var users: [Api.User]
|
||||
public init(flags: Int32, queryId: Int64, nextOffset: String?, switchPm: Api.InlineBotSwitchPM?, switchWebview: Api.InlineBotWebView?, results: [Api.BotInlineResult], cacheTime: Int32, users: [Api.User]) {
|
||||
self.flags = flags
|
||||
self.queryId = queryId
|
||||
self.nextOffset = nextOffset
|
||||
self.switchPm = switchPm
|
||||
self.switchWebview = switchWebview
|
||||
self.results = results
|
||||
self.cacheTime = cacheTime
|
||||
self.users = users
|
||||
}
|
||||
}
|
||||
case botResults(Cons_botResults)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -318,7 +338,15 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum ChatAdminsWithInvites: TypeConstructorDescription {
|
||||
case chatAdminsWithInvites(admins: [Api.ChatAdminWithInvites], users: [Api.User])
|
||||
public class Cons_chatAdminsWithInvites {
|
||||
public var admins: [Api.ChatAdminWithInvites]
|
||||
public var users: [Api.User]
|
||||
public init(admins: [Api.ChatAdminWithInvites], users: [Api.User]) {
|
||||
self.admins = admins
|
||||
self.users = users
|
||||
}
|
||||
}
|
||||
case chatAdminsWithInvites(Cons_chatAdminsWithInvites)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -347,7 +375,17 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum ChatFull: TypeConstructorDescription {
|
||||
case chatFull(fullChat: Api.ChatFull, chats: [Api.Chat], users: [Api.User])
|
||||
public class Cons_chatFull {
|
||||
public var fullChat: Api.ChatFull
|
||||
public var chats: [Api.Chat]
|
||||
public var users: [Api.User]
|
||||
public init(fullChat: Api.ChatFull, chats: [Api.Chat], users: [Api.User]) {
|
||||
self.fullChat = fullChat
|
||||
self.chats = chats
|
||||
self.users = users
|
||||
}
|
||||
}
|
||||
case chatFull(Cons_chatFull)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -376,7 +414,17 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum ChatInviteImporters: TypeConstructorDescription {
|
||||
case chatInviteImporters(count: Int32, importers: [Api.ChatInviteImporter], users: [Api.User])
|
||||
public class Cons_chatInviteImporters {
|
||||
public var count: Int32
|
||||
public var importers: [Api.ChatInviteImporter]
|
||||
public var users: [Api.User]
|
||||
public init(count: Int32, importers: [Api.ChatInviteImporter], users: [Api.User]) {
|
||||
self.count = count
|
||||
self.importers = importers
|
||||
self.users = users
|
||||
}
|
||||
}
|
||||
case chatInviteImporters(Cons_chatInviteImporters)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -405,8 +453,22 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum Chats: TypeConstructorDescription {
|
||||
case chats(chats: [Api.Chat])
|
||||
case chatsSlice(count: Int32, chats: [Api.Chat])
|
||||
public class Cons_chats {
|
||||
public var chats: [Api.Chat]
|
||||
public init(chats: [Api.Chat]) {
|
||||
self.chats = chats
|
||||
}
|
||||
}
|
||||
public class Cons_chatsSlice {
|
||||
public var count: Int32
|
||||
public var chats: [Api.Chat]
|
||||
public init(count: Int32, chats: [Api.Chat]) {
|
||||
self.count = count
|
||||
self.chats = chats
|
||||
}
|
||||
}
|
||||
case chats(Cons_chats)
|
||||
case chatsSlice(Cons_chatsSlice)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -442,7 +504,13 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum CheckedHistoryImportPeer: TypeConstructorDescription {
|
||||
case checkedHistoryImportPeer(confirmText: String)
|
||||
public class Cons_checkedHistoryImportPeer {
|
||||
public var confirmText: String
|
||||
public init(confirmText: String) {
|
||||
self.confirmText = confirmText
|
||||
}
|
||||
}
|
||||
case checkedHistoryImportPeer(Cons_checkedHistoryImportPeer)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -471,8 +539,26 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum DhConfig: TypeConstructorDescription {
|
||||
case dhConfig(g: Int32, p: Buffer, version: Int32, random: Buffer)
|
||||
case dhConfigNotModified(random: Buffer)
|
||||
public class Cons_dhConfig {
|
||||
public var g: Int32
|
||||
public var p: Buffer
|
||||
public var version: Int32
|
||||
public var random: Buffer
|
||||
public init(g: Int32, p: Buffer, version: Int32, random: Buffer) {
|
||||
self.g = g
|
||||
self.p = p
|
||||
self.version = version
|
||||
self.random = random
|
||||
}
|
||||
}
|
||||
public class Cons_dhConfigNotModified {
|
||||
public var random: Buffer
|
||||
public init(random: Buffer) {
|
||||
self.random = random
|
||||
}
|
||||
}
|
||||
case dhConfig(Cons_dhConfig)
|
||||
case dhConfigNotModified(Cons_dhConfigNotModified)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -508,7 +594,15 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum DialogFilters: TypeConstructorDescription {
|
||||
case dialogFilters(flags: Int32, filters: [Api.DialogFilter])
|
||||
public class Cons_dialogFilters {
|
||||
public var flags: Int32
|
||||
public var filters: [Api.DialogFilter]
|
||||
public init(flags: Int32, filters: [Api.DialogFilter]) {
|
||||
self.flags = flags
|
||||
self.filters = filters
|
||||
}
|
||||
}
|
||||
case dialogFilters(Cons_dialogFilters)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -537,9 +631,41 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum Dialogs: TypeConstructorDescription {
|
||||
case dialogs(dialogs: [Api.Dialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User])
|
||||
case dialogsNotModified(count: Int32)
|
||||
case dialogsSlice(count: Int32, dialogs: [Api.Dialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User])
|
||||
public class Cons_dialogs {
|
||||
public var dialogs: [Api.Dialog]
|
||||
public var messages: [Api.Message]
|
||||
public var chats: [Api.Chat]
|
||||
public var users: [Api.User]
|
||||
public init(dialogs: [Api.Dialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) {
|
||||
self.dialogs = dialogs
|
||||
self.messages = messages
|
||||
self.chats = chats
|
||||
self.users = users
|
||||
}
|
||||
}
|
||||
public class Cons_dialogsNotModified {
|
||||
public var count: Int32
|
||||
public init(count: Int32) {
|
||||
self.count = count
|
||||
}
|
||||
}
|
||||
public class Cons_dialogsSlice {
|
||||
public var count: Int32
|
||||
public var dialogs: [Api.Dialog]
|
||||
public var messages: [Api.Message]
|
||||
public var chats: [Api.Chat]
|
||||
public var users: [Api.User]
|
||||
public init(count: Int32, dialogs: [Api.Dialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) {
|
||||
self.count = count
|
||||
self.dialogs = dialogs
|
||||
self.messages = messages
|
||||
self.chats = chats
|
||||
self.users = users
|
||||
}
|
||||
}
|
||||
case dialogs(Cons_dialogs)
|
||||
case dialogsNotModified(Cons_dialogsNotModified)
|
||||
case dialogsSlice(Cons_dialogsSlice)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -582,7 +708,27 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum DiscussionMessage: TypeConstructorDescription {
|
||||
case discussionMessage(flags: Int32, messages: [Api.Message], maxId: Int32?, readInboxMaxId: Int32?, readOutboxMaxId: Int32?, unreadCount: Int32, chats: [Api.Chat], users: [Api.User])
|
||||
public class Cons_discussionMessage {
|
||||
public var flags: Int32
|
||||
public var messages: [Api.Message]
|
||||
public var maxId: Int32?
|
||||
public var readInboxMaxId: Int32?
|
||||
public var readOutboxMaxId: Int32?
|
||||
public var unreadCount: Int32
|
||||
public var chats: [Api.Chat]
|
||||
public var users: [Api.User]
|
||||
public init(flags: Int32, messages: [Api.Message], maxId: Int32?, readInboxMaxId: Int32?, readOutboxMaxId: Int32?, unreadCount: Int32, chats: [Api.Chat], users: [Api.User]) {
|
||||
self.flags = flags
|
||||
self.messages = messages
|
||||
self.maxId = maxId
|
||||
self.readInboxMaxId = readInboxMaxId
|
||||
self.readOutboxMaxId = readOutboxMaxId
|
||||
self.unreadCount = unreadCount
|
||||
self.chats = chats
|
||||
self.users = users
|
||||
}
|
||||
}
|
||||
case discussionMessage(Cons_discussionMessage)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -611,7 +757,23 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum EmojiGameInfo: TypeConstructorDescription {
|
||||
case emojiGameDiceInfo(flags: Int32, gameHash: String, prevStake: Int64, currentStreak: Int32, params: [Int32], playsLeft: Int32?)
|
||||
public class Cons_emojiGameDiceInfo {
|
||||
public var flags: Int32
|
||||
public var gameHash: String
|
||||
public var prevStake: Int64
|
||||
public var currentStreak: Int32
|
||||
public var params: [Int32]
|
||||
public var playsLeft: Int32?
|
||||
public init(flags: Int32, gameHash: String, prevStake: Int64, currentStreak: Int32, params: [Int32], playsLeft: Int32?) {
|
||||
self.flags = flags
|
||||
self.gameHash = gameHash
|
||||
self.prevStake = prevStake
|
||||
self.currentStreak = currentStreak
|
||||
self.params = params
|
||||
self.playsLeft = playsLeft
|
||||
}
|
||||
}
|
||||
case emojiGameDiceInfo(Cons_emojiGameDiceInfo)
|
||||
case emojiGameUnavailable
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
|
|
@ -648,7 +810,17 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum EmojiGameOutcome: TypeConstructorDescription {
|
||||
case emojiGameOutcome(seed: Buffer, stakeTonAmount: Int64, tonAmount: Int64)
|
||||
public class Cons_emojiGameOutcome {
|
||||
public var seed: Buffer
|
||||
public var stakeTonAmount: Int64
|
||||
public var tonAmount: Int64
|
||||
public init(seed: Buffer, stakeTonAmount: Int64, tonAmount: Int64) {
|
||||
self.seed = seed
|
||||
self.stakeTonAmount = stakeTonAmount
|
||||
self.tonAmount = tonAmount
|
||||
}
|
||||
}
|
||||
case emojiGameOutcome(Cons_emojiGameOutcome)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -677,7 +849,15 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum EmojiGroups: TypeConstructorDescription {
|
||||
case emojiGroups(hash: Int32, groups: [Api.EmojiGroup])
|
||||
public class Cons_emojiGroups {
|
||||
public var hash: Int32
|
||||
public var groups: [Api.EmojiGroup]
|
||||
public init(hash: Int32, groups: [Api.EmojiGroup]) {
|
||||
self.hash = hash
|
||||
self.groups = groups
|
||||
}
|
||||
}
|
||||
case emojiGroups(Cons_emojiGroups)
|
||||
case emojiGroupsNotModified
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
|
|
@ -714,8 +894,26 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum ExportedChatInvite: TypeConstructorDescription {
|
||||
case exportedChatInvite(invite: Api.ExportedChatInvite, users: [Api.User])
|
||||
case exportedChatInviteReplaced(invite: Api.ExportedChatInvite, newInvite: Api.ExportedChatInvite, users: [Api.User])
|
||||
public class Cons_exportedChatInvite {
|
||||
public var invite: Api.ExportedChatInvite
|
||||
public var users: [Api.User]
|
||||
public init(invite: Api.ExportedChatInvite, users: [Api.User]) {
|
||||
self.invite = invite
|
||||
self.users = users
|
||||
}
|
||||
}
|
||||
public class Cons_exportedChatInviteReplaced {
|
||||
public var invite: Api.ExportedChatInvite
|
||||
public var newInvite: Api.ExportedChatInvite
|
||||
public var users: [Api.User]
|
||||
public init(invite: Api.ExportedChatInvite, newInvite: Api.ExportedChatInvite, users: [Api.User]) {
|
||||
self.invite = invite
|
||||
self.newInvite = newInvite
|
||||
self.users = users
|
||||
}
|
||||
}
|
||||
case exportedChatInvite(Cons_exportedChatInvite)
|
||||
case exportedChatInviteReplaced(Cons_exportedChatInviteReplaced)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -751,7 +949,17 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum ExportedChatInvites: TypeConstructorDescription {
|
||||
case exportedChatInvites(count: Int32, invites: [Api.ExportedChatInvite], users: [Api.User])
|
||||
public class Cons_exportedChatInvites {
|
||||
public var count: Int32
|
||||
public var invites: [Api.ExportedChatInvite]
|
||||
public var users: [Api.User]
|
||||
public init(count: Int32, invites: [Api.ExportedChatInvite], users: [Api.User]) {
|
||||
self.count = count
|
||||
self.invites = invites
|
||||
self.users = users
|
||||
}
|
||||
}
|
||||
case exportedChatInvites(Cons_exportedChatInvites)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
public extension Api.messages {
|
||||
enum FavedStickers: TypeConstructorDescription {
|
||||
case favedStickers(hash: Int64, packs: [Api.StickerPack], stickers: [Api.Document])
|
||||
public class Cons_favedStickers {
|
||||
public var hash: Int64
|
||||
public var packs: [Api.StickerPack]
|
||||
public var stickers: [Api.Document]
|
||||
public init(hash: Int64, packs: [Api.StickerPack], stickers: [Api.Document]) {
|
||||
self.hash = hash
|
||||
self.packs = packs
|
||||
self.stickers = stickers
|
||||
}
|
||||
}
|
||||
case favedStickers(Cons_favedStickers)
|
||||
case favedStickersNotModified
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
|
|
@ -37,8 +47,28 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum FeaturedStickers: TypeConstructorDescription {
|
||||
case featuredStickers(flags: Int32, hash: Int64, count: Int32, sets: [Api.StickerSetCovered], unread: [Int64])
|
||||
case featuredStickersNotModified(count: Int32)
|
||||
public class Cons_featuredStickers {
|
||||
public var flags: Int32
|
||||
public var hash: Int64
|
||||
public var count: Int32
|
||||
public var sets: [Api.StickerSetCovered]
|
||||
public var unread: [Int64]
|
||||
public init(flags: Int32, hash: Int64, count: Int32, sets: [Api.StickerSetCovered], unread: [Int64]) {
|
||||
self.flags = flags
|
||||
self.hash = hash
|
||||
self.count = count
|
||||
self.sets = sets
|
||||
self.unread = unread
|
||||
}
|
||||
}
|
||||
public class Cons_featuredStickersNotModified {
|
||||
public var count: Int32
|
||||
public init(count: Int32) {
|
||||
self.count = count
|
||||
}
|
||||
}
|
||||
case featuredStickers(Cons_featuredStickers)
|
||||
case featuredStickersNotModified(Cons_featuredStickersNotModified)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -74,7 +104,25 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum ForumTopics: TypeConstructorDescription {
|
||||
case forumTopics(flags: Int32, count: Int32, topics: [Api.ForumTopic], messages: [Api.Message], chats: [Api.Chat], users: [Api.User], pts: Int32)
|
||||
public class Cons_forumTopics {
|
||||
public var flags: Int32
|
||||
public var count: Int32
|
||||
public var topics: [Api.ForumTopic]
|
||||
public var messages: [Api.Message]
|
||||
public var chats: [Api.Chat]
|
||||
public var users: [Api.User]
|
||||
public var pts: Int32
|
||||
public init(flags: Int32, count: Int32, topics: [Api.ForumTopic], messages: [Api.Message], chats: [Api.Chat], users: [Api.User], pts: Int32) {
|
||||
self.flags = flags
|
||||
self.count = count
|
||||
self.topics = topics
|
||||
self.messages = messages
|
||||
self.chats = chats
|
||||
self.users = users
|
||||
self.pts = pts
|
||||
}
|
||||
}
|
||||
case forumTopics(Cons_forumTopics)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -103,7 +151,15 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum FoundStickerSets: TypeConstructorDescription {
|
||||
case foundStickerSets(hash: Int64, sets: [Api.StickerSetCovered])
|
||||
public class Cons_foundStickerSets {
|
||||
public var hash: Int64
|
||||
public var sets: [Api.StickerSetCovered]
|
||||
public init(hash: Int64, sets: [Api.StickerSetCovered]) {
|
||||
self.hash = hash
|
||||
self.sets = sets
|
||||
}
|
||||
}
|
||||
case foundStickerSets(Cons_foundStickerSets)
|
||||
case foundStickerSetsNotModified
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
|
|
@ -140,8 +196,28 @@ public extension Api.messages {
|
|||
}
|
||||
public extension Api.messages {
|
||||
enum FoundStickers: TypeConstructorDescription {
|
||||
case foundStickers(flags: Int32, nextOffset: Int32?, hash: Int64, stickers: [Api.Document])
|
||||
case foundStickersNotModified(flags: Int32, nextOffset: Int32?)
|
||||
public class Cons_foundStickers {
|
||||
public var flags: Int32
|
||||
public var nextOffset: Int32?
|
||||
public var hash: Int64
|
||||
public var stickers: [Api.Document]
|
||||
public init(flags: Int32, nextOffset: Int32?, hash: Int64, stickers: [Api.Document]) {
|
||||
self.flags = flags
|
||||
self.nextOffset = nextOffset
|
||||
self.hash = hash
|
||||
self.stickers = stickers
|
||||
}
|
||||
}
|
||||
public class Cons_foundStickersNotModified {
|
||||
public var flags: Int32
|
||||
public var nextOffset: Int32?
|
||||
public init(flags: Int32, nextOffset: Int32?) {
|
||||
self.flags = flags
|
||||
self.nextOffset = nextOffset
|
||||
}
|
||||
}
|
||||
case foundStickers(Cons_foundStickers)
|
||||
case foundStickersNotModified(Cons_foundStickersNotModified)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
|
|||
|
|
@ -638,7 +638,8 @@ extension ChatContextResultWebView {
|
|||
extension ChatContextResultCollection {
|
||||
convenience init(apiResults: Api.messages.BotResults, botId: PeerId, peerId: PeerId, query: String, geoPoint: (Double, Double)?) {
|
||||
switch apiResults {
|
||||
case let .botResults(flags, queryId, nextOffset, switchPm, switchWebView, results, cacheTime, _):
|
||||
case let .botResults(botResultsData):
|
||||
let (flags, queryId, nextOffset, switchPm, switchWebView, results, cacheTime, _) = (botResultsData.flags, botResultsData.queryId, botResultsData.nextOffset, botResultsData.switchPm, botResultsData.switchWebview, botResultsData.results, botResultsData.cacheTime, botResultsData.users)
|
||||
var switchPeer: ChatContextResultSwitchPeer?
|
||||
if let switchPm = switchPm {
|
||||
switchPeer = ChatContextResultSwitchPeer(apiSwitchPeer: switchPm)
|
||||
|
|
|
|||
|
|
@ -504,7 +504,8 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI
|
|||
var gameOutcome: TelegramMediaDice.GameOutcome?
|
||||
var tonAmount: Int64?
|
||||
switch apiGameOutcome {
|
||||
case let .emojiGameOutcome(seed, stakeTonAmount, outcomeTonAmount):
|
||||
case let .emojiGameOutcome(emojiGameOutcomeData):
|
||||
let (seed, stakeTonAmount, outcomeTonAmount) = (emojiGameOutcomeData.seed, emojiGameOutcomeData.stakeTonAmount, emojiGameOutcomeData.tonAmount)
|
||||
gameOutcome = TelegramMediaDice.GameOutcome(seed: seed.makeData(), tonAmount: outcomeTonAmount)
|
||||
tonAmount = stakeTonAmount
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -985,7 +985,8 @@ func _internal_requestMessageHistoryThreads(accountPeerId: PeerId, postbox: Post
|
|||
}
|
||||
|> mapToSignal { result -> Signal<LoadMessageHistoryThreadsResult, LoadMessageHistoryThreadsError> in
|
||||
switch result {
|
||||
case let .forumTopics(_, _, topics, messages, chats, users, pts):
|
||||
case let .forumTopics(forumTopicsData):
|
||||
let (topics, messages, chats, users, pts) = (forumTopicsData.topics, forumTopicsData.messages, forumTopicsData.chats, forumTopicsData.users, forumTopicsData.pts)
|
||||
var items: [LoadMessageHistoryThreadsResult.Item] = []
|
||||
var pinnedIds: [Int64] = []
|
||||
|
||||
|
|
@ -1206,7 +1207,8 @@ func _internal_forumChannelTopicNotificationExceptions(account: Account, id: Eng
|
|||
var infoMapping: [Int64: EngineMessageHistoryThread.Info] = [:]
|
||||
|
||||
switch result {
|
||||
case let .forumTopics(_, _, topics, _, _, _, _):
|
||||
case let .forumTopics(forumTopicsData):
|
||||
let topics = forumTopicsData.topics
|
||||
for topic in topics {
|
||||
switch topic {
|
||||
case let .forumTopic(forumTopicData):
|
||||
|
|
|
|||
|
|
@ -35,9 +35,11 @@ public func actualizedPeer(accountPeerId: PeerId, postbox: Postbox, network: Net
|
|||
if let result = result {
|
||||
let chats: [Api.Chat]
|
||||
switch result {
|
||||
case let .chats(apiChats):
|
||||
case let .chats(chatsData):
|
||||
let apiChats = chatsData.chats
|
||||
chats = apiChats
|
||||
case let .chatsSlice(_, apiChats):
|
||||
case let .chatsSlice(chatsSliceData):
|
||||
let apiChats = chatsSliceData.chats
|
||||
chats = apiChats
|
||||
}
|
||||
let parsedPeersValue = AccumulatedPeers(transaction: transaction, chats: chats, users: [])
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ func validatedEncryptionConfig(postbox: Postbox, network: Network) -> Signal<Sec
|
|||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<SecretChatEncryptionConfig, NoError> in
|
||||
switch result {
|
||||
case let .dhConfig(g, p, version, _):
|
||||
case let .dhConfig(dhConfigData):
|
||||
let (g, p, version) = (dhConfigData.g, dhConfigData.p, dhConfigData.version)
|
||||
if !MTCheckIsSafeG(UInt32(g)) {
|
||||
Logger.shared.log("SecretChatEncryptionConfig", "Invalid g")
|
||||
return .complete()
|
||||
|
|
@ -26,7 +27,7 @@ func validatedEncryptionConfig(postbox: Postbox, network: Network) -> Signal<Sec
|
|||
return .never()
|
||||
}
|
||||
return .single(SecretChatEncryptionConfig(g: g, p: MemoryBuffer(p), version: version))
|
||||
case .dhConfigNotModified(_):
|
||||
case .dhConfigNotModified:
|
||||
assertionFailure()
|
||||
return .never()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2102,7 +2102,8 @@ final class FetchedForumThreads {
|
|||
|
||||
convenience init(forumTopics: Api.messages.ForumTopics) {
|
||||
switch forumTopics {
|
||||
case let .forumTopics(flags, count, topics, messages, chats, users, pts):
|
||||
case let .forumTopics(forumTopicsData):
|
||||
let (flags, count, topics, messages, chats, users, pts) = (forumTopicsData.flags, forumTopicsData.count, forumTopicsData.topics, forumTopicsData.messages, forumTopicsData.chats, forumTopicsData.users, forumTopicsData.pts)
|
||||
let orderByDate = (flags & (1 << 0)) != 0
|
||||
self.init(items: topics.map(Item.forum), totalCount: Int(count), orderByDate: orderByDate, pts: pts, messages: messages, users: users, chats: chats)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,7 +159,8 @@ func managedSynchronizeEmojiSearchCategories(postbox: Postbox, network: Network,
|
|||
|> mapToSignal { result -> Signal<Never, NoError> in
|
||||
return postbox.transaction { transaction -> Signal<Never, NoError> in
|
||||
switch result {
|
||||
case let .emojiGroups(hash, groups):
|
||||
case let .emojiGroups(emojiGroupsData):
|
||||
let (hash, groups) = (emojiGroupsData.hash, emojiGroupsData.groups)
|
||||
let categories = EmojiSearchCategories(
|
||||
hash: hash,
|
||||
groups: groups.compactMap { item -> EmojiSearchCategories.Group? in
|
||||
|
|
|
|||
|
|
@ -30,9 +30,11 @@ struct ParsedDialogs {
|
|||
|
||||
private func extractDialogsData(dialogs: Api.messages.Dialogs) -> (apiDialogs: [Api.Dialog], apiMessages: [Api.Message], apiChats: [Api.Chat], apiUsers: [Api.User], apiIsAtLowestBoundary: Bool) {
|
||||
switch dialogs {
|
||||
case let .dialogs(dialogs, messages, chats, users):
|
||||
case let .dialogs(dialogsData):
|
||||
let (dialogs, messages, chats, users) = (dialogsData.dialogs, dialogsData.messages, dialogsData.chats, dialogsData.users)
|
||||
return (dialogs, messages, chats, users, true)
|
||||
case let .dialogsSlice(_, dialogs, messages, chats, users):
|
||||
case let .dialogsSlice(dialogsSliceData):
|
||||
let (_, dialogs, messages, chats, users) = (dialogsSliceData.count, dialogsSliceData.dialogs, dialogsSliceData.messages, dialogsSliceData.chats, dialogsSliceData.users)
|
||||
return (dialogs, messages, chats, users, false)
|
||||
case .dialogsNotModified:
|
||||
assertionFailure()
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ public enum EmojiGameInfo: Codable, Equatable {
|
|||
extension EmojiGameInfo {
|
||||
init(apiEmojiGameInfo: Api.messages.EmojiGameInfo) {
|
||||
switch apiEmojiGameInfo {
|
||||
case let .emojiGameDiceInfo(_, gameHash, prevStake, currentStreak, params, playsLeft):
|
||||
case let .emojiGameDiceInfo(emojiGameDiceInfoData):
|
||||
let (gameHash, prevStake, currentStreak, params, playsLeft) = (emojiGameDiceInfoData.gameHash, emojiGameDiceInfoData.prevStake, emojiGameDiceInfoData.currentStreak, emojiGameDiceInfoData.params, emojiGameDiceInfoData.playsLeft)
|
||||
self = .available(Info(gameHash: gameHash, previousStake: prevStake, currentStreak: currentStreak, parameters: params, playsLeft: playsLeft))
|
||||
case .emojiGameUnavailable:
|
||||
self = .unavailable
|
||||
|
|
|
|||
|
|
@ -105,7 +105,8 @@ func managedSavedStickers(postbox: Postbox, network: Network, forceFetch: Bool =
|
|||
switch result {
|
||||
case .favedStickersNotModified:
|
||||
return .single(nil)
|
||||
case let .favedStickers(_, packs, stickers):
|
||||
case let .favedStickers(favedStickersData):
|
||||
let (packs, stickers) = (favedStickersData.packs, favedStickersData.stickers)
|
||||
var fileStringRepresentations: [MediaId: [String]] = [:]
|
||||
for pack in packs {
|
||||
switch pack {
|
||||
|
|
|
|||
|
|
@ -171,7 +171,8 @@ func updatedFeaturedStickerPacks(network: Network, postbox: Postbox, category: F
|
|||
switch result {
|
||||
case .featuredStickersNotModified:
|
||||
return .single(.notModified)
|
||||
case let .featuredStickers(flags, _, _, sets, unread):
|
||||
case let .featuredStickers(featuredStickersData):
|
||||
let (flags, sets, unread) = (featuredStickersData.flags, featuredStickersData.sets, featuredStickersData.unread)
|
||||
return resolveMissingStickerSets(network: network, postbox: postbox, stickerSets: sets, ignorePacksWithHashes: initialPackMap.filter { $0.value.topItems.count > 1 }.mapValues({ item in
|
||||
item.info.hash
|
||||
}))
|
||||
|
|
@ -208,7 +209,8 @@ func updatedFeaturedStickerPacks(network: Network, postbox: Postbox, category: F
|
|||
switch result {
|
||||
case .featuredStickersNotModified:
|
||||
return .single(.notModified)
|
||||
case let .featuredStickers(flags, _, _, sets, unread):
|
||||
case let .featuredStickers(featuredStickersData):
|
||||
let (flags, sets, unread) = (featuredStickersData.flags, featuredStickersData.sets, featuredStickersData.unread)
|
||||
return resolveMissingStickerSets(network: network, postbox: postbox, stickerSets: sets, ignorePacksWithHashes: initialPackMap.mapValues({ item in
|
||||
item.info.hash
|
||||
}))
|
||||
|
|
@ -271,7 +273,8 @@ public func requestOldFeaturedStickerPacks(network: Network, postbox: Postbox, o
|
|||
switch result {
|
||||
case .featuredStickersNotModified:
|
||||
return []
|
||||
case let .featuredStickers(_, _, _, sets, unread):
|
||||
case let .featuredStickers(featuredStickersData):
|
||||
let (sets, unread) = (featuredStickersData.sets, featuredStickersData.unread)
|
||||
let unreadIds = Set(unread)
|
||||
var updatedPacks: [FeaturedStickerPackItem] = []
|
||||
for set in sets {
|
||||
|
|
|
|||
|
|
@ -245,7 +245,8 @@ public extension TelegramEngine {
|
|||
}
|
||||
|> map { result -> CheckPeerImportResult in
|
||||
switch result {
|
||||
case let .checkedHistoryImportPeer(confirmText):
|
||||
case let .checkedHistoryImportPeer(checkedHistoryImportPeerData):
|
||||
let confirmText = checkedHistoryImportPeerData.confirmText
|
||||
if confirmText.isEmpty {
|
||||
return .allowed
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1439,9 +1439,19 @@ func _internal_getPossibleStarRefBotTargets(account: Account) -> Signal<[EngineP
|
|||
|
||||
if let apiChannels {
|
||||
switch apiChannels {
|
||||
case let .chats(chats), let .chatsSlice(_, chats):
|
||||
case let .chats(chatsData):
|
||||
let chats = chatsData.chats
|
||||
updatePeers(transaction: transaction, accountPeerId: account.peerId, peers: AccumulatedPeers(chats: chats, users: []))
|
||||
|
||||
|
||||
for chat in chats {
|
||||
if let peer = transaction.getPeer(chat.peerId) {
|
||||
result.append(EnginePeer(peer))
|
||||
}
|
||||
}
|
||||
case let .chatsSlice(chatsSliceData):
|
||||
let chats = chatsSliceData.chats
|
||||
updatePeers(transaction: transaction, accountPeerId: account.peerId, peers: AccumulatedPeers(chats: chats, users: []))
|
||||
|
||||
for chat in chats {
|
||||
if let peer = transaction.getPeer(chat.peerId) {
|
||||
result.append(EnginePeer(peer))
|
||||
|
|
|
|||
|
|
@ -156,7 +156,8 @@ private class ReplyThreadHistoryContextImpl {
|
|||
|> mapToSignal { discussionMessage -> Signal<DiscussionMessage, FetchChannelReplyThreadMessageError> in
|
||||
return account.postbox.transaction { transaction -> Signal<DiscussionMessage, FetchChannelReplyThreadMessageError> in
|
||||
switch discussionMessage {
|
||||
case let .discussionMessage(_, messages, maxId, readInboxMaxId, readOutboxMaxId, unreadCount, chats, users):
|
||||
case let .discussionMessage(discussionMessageData):
|
||||
let (messages, maxId, readInboxMaxId, readOutboxMaxId, unreadCount, chats, users) = (discussionMessageData.messages, discussionMessageData.maxId, discussionMessageData.readInboxMaxId, discussionMessageData.readOutboxMaxId, discussionMessageData.unreadCount, discussionMessageData.chats, discussionMessageData.users)
|
||||
let parsedMessages = messages.compactMap { message -> StoreMessage? in
|
||||
StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForumOrMonoForum)
|
||||
}
|
||||
|
|
@ -476,7 +477,8 @@ private class ReplyThreadHistoryContextImpl {
|
|||
let validateSignal = strongSelf.account.network.request(Api.functions.messages.getDiscussionMessage(peer: inputPeer, msgId: Int32(clamping: threadId)))
|
||||
|> map { result -> (MessageId?, Int) in
|
||||
switch result {
|
||||
case let .discussionMessage(_, _, _, readInboxMaxId, _, unreadCount, _, _):
|
||||
case let .discussionMessage(discussionMessageData):
|
||||
let (readInboxMaxId, unreadCount) = (discussionMessageData.readInboxMaxId, discussionMessageData.unreadCount)
|
||||
return (readInboxMaxId.flatMap({ MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: $0) }), Int(unreadCount))
|
||||
}
|
||||
}
|
||||
|
|
@ -670,7 +672,8 @@ func _internal_fetchChannelReplyThreadMessage(account: Account, messageId: Messa
|
|||
}
|
||||
return account.postbox.transaction { transaction -> DiscussionMessage? in
|
||||
switch discussionMessage {
|
||||
case let .discussionMessage(_, messages, maxId, readInboxMaxId, readOutboxMaxId, unreadCount, chats, users):
|
||||
case let .discussionMessage(discussionMessageData):
|
||||
let (messages, maxId, readInboxMaxId, readOutboxMaxId, unreadCount, chats, users) = (discussionMessageData.messages, discussionMessageData.maxId, discussionMessageData.readInboxMaxId, discussionMessageData.readOutboxMaxId, discussionMessageData.unreadCount, discussionMessageData.chats, discussionMessageData.users)
|
||||
let parsedMessages = messages.compactMap { message -> StoreMessage? in
|
||||
StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForumOrMonoForum)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1032,14 +1032,16 @@ func _internal_updatedRemotePeer(accountPeerId: PeerId, postbox: Postbox, networ
|
|||
return postbox.transaction { transaction -> Signal<Peer, UpdatedRemotePeerError> in
|
||||
let chats: [Api.Chat]
|
||||
switch result {
|
||||
case let .chats(c):
|
||||
case let .chats(chatsData):
|
||||
let c = chatsData.chats
|
||||
chats = c
|
||||
case let .chatsSlice(_, c):
|
||||
case let .chatsSlice(chatsSliceData):
|
||||
let c = chatsSliceData.chats
|
||||
chats = c
|
||||
}
|
||||
|
||||
|
||||
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: [])
|
||||
|
||||
|
||||
if let firstId = chats.first?.peerId, let updatedPeer = parsedPeers.get(firstId), updatedPeer.id == peer.id {
|
||||
return postbox.transaction { transaction -> Peer in
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
|
||||
|
|
@ -1063,9 +1065,11 @@ func _internal_updatedRemotePeer(accountPeerId: PeerId, postbox: Postbox, networ
|
|||
return postbox.transaction { transaction -> Signal<Peer, UpdatedRemotePeerError> in
|
||||
let chats: [Api.Chat]
|
||||
switch result {
|
||||
case let .chats(c):
|
||||
case let .chats(chatsData):
|
||||
let c = chatsData.chats
|
||||
chats = c
|
||||
case let .chatsSlice(_, c):
|
||||
case let .chatsSlice(chatsSliceData):
|
||||
let c = chatsSliceData.chats
|
||||
chats = c
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -558,7 +558,8 @@ func _internal_adminedPublicChannels(account: Account, scope: AdminedPublicChann
|
|||
var subscriberCounts: [PeerId: Int] = [:]
|
||||
let parsedPeers: AccumulatedPeers
|
||||
switch result {
|
||||
case let .chats(apiChats):
|
||||
case let .chats(chatsData):
|
||||
let apiChats = chatsData.chats
|
||||
chats = apiChats
|
||||
for chat in apiChats {
|
||||
if case let .channel(channelData) = chat {
|
||||
|
|
@ -566,7 +567,8 @@ func _internal_adminedPublicChannels(account: Account, scope: AdminedPublicChann
|
|||
subscriberCounts[chat.peerId] = participantsCount.flatMap(Int.init)
|
||||
}
|
||||
}
|
||||
case let .chatsSlice(_, apiChats):
|
||||
case let .chatsSlice(chatsSliceData):
|
||||
let apiChats = chatsSliceData.chats
|
||||
chats = apiChats
|
||||
}
|
||||
parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: [])
|
||||
|
|
@ -626,9 +628,11 @@ func _internal_channelsForStories(account: Account) -> Signal<[Peer], NoError> {
|
|||
let chats: [Api.Chat]
|
||||
let parsedPeers: AccumulatedPeers
|
||||
switch result {
|
||||
case let .chats(apiChats):
|
||||
case let .chats(chatsData):
|
||||
let apiChats = chatsData.chats
|
||||
chats = apiChats
|
||||
case let .chatsSlice(_, apiChats):
|
||||
case let .chatsSlice(chatsSliceData):
|
||||
let apiChats = chatsSliceData.chats
|
||||
chats = apiChats
|
||||
}
|
||||
parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: [])
|
||||
|
|
@ -688,9 +692,11 @@ func _internal_channelsForPublicReaction(account: Account, useLocalCache: Bool)
|
|||
let chats: [Api.Chat]
|
||||
let parsedPeers: AccumulatedPeers
|
||||
switch result {
|
||||
case let .chats(apiChats):
|
||||
case let .chats(chatsData):
|
||||
let apiChats = chatsData.chats
|
||||
chats = apiChats
|
||||
case let .chatsSlice(_, apiChats):
|
||||
case let .chatsSlice(chatsSliceData):
|
||||
let apiChats = chatsSliceData.chats
|
||||
chats = apiChats
|
||||
}
|
||||
parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: [])
|
||||
|
|
|
|||
|
|
@ -104,10 +104,12 @@ func _internal_requestRecommendedChannels(account: Account, peerId: EnginePeer.I
|
|||
let parsedPeers: AccumulatedPeers
|
||||
var count: Int32
|
||||
switch result {
|
||||
case let .chats(apiChats):
|
||||
case let .chats(chatsData):
|
||||
let apiChats = chatsData.chats
|
||||
chats = apiChats
|
||||
count = Int32(apiChats.count)
|
||||
case let .chatsSlice(apiCount, apiChats):
|
||||
case let .chatsSlice(chatsSliceData):
|
||||
let (apiCount, apiChats) = (chatsSliceData.count, chatsSliceData.chats)
|
||||
chats = apiChats
|
||||
count = apiCount
|
||||
}
|
||||
|
|
|
|||
|
|
@ -579,7 +579,8 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net
|
|||
|> mapToSignal { result -> Signal<([ChatListFilter], Bool), RequestChatListFiltersError> in
|
||||
return postbox.transaction { transaction -> ([ChatListFilter], [Api.InputPeer], [Api.InputPeer], Bool) in
|
||||
switch result {
|
||||
case let .dialogFilters(flags, apiFilters):
|
||||
case let .dialogFilters(dialogFiltersData):
|
||||
let (flags, apiFilters) = (dialogFiltersData.flags, dialogFiltersData.filters)
|
||||
let tagsEnabled = (flags & (1 << 0)) != 0
|
||||
|
||||
var filters: [ChatListFilter] = []
|
||||
|
|
@ -749,7 +750,11 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net
|
|||
if let result = result {
|
||||
let parsedPeers: AccumulatedPeers
|
||||
switch result {
|
||||
case .chats(let chats), .chatsSlice(_, let chats):
|
||||
case let .chats(chatsData):
|
||||
let chats = chatsData.chats
|
||||
parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: [])
|
||||
case let .chatsSlice(chatsSliceData):
|
||||
let chats = chatsSliceData.chats
|
||||
parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: [])
|
||||
}
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
|
||||
|
|
@ -773,7 +778,11 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net
|
|||
if let result = result {
|
||||
let parsedPeers: AccumulatedPeers
|
||||
switch result {
|
||||
case .chats(let chats), .chatsSlice(_, let chats):
|
||||
case let .chats(chatsData):
|
||||
let chats = chatsData.chats
|
||||
parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: [])
|
||||
case let .chatsSlice(chatsSliceData):
|
||||
let chats = chatsSliceData.chats
|
||||
parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: [])
|
||||
}
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ func _internal_findChannelById(accountPeerId: PeerId, postbox: Postbox, network:
|
|||
}
|
||||
let chats: [Api.Chat]
|
||||
switch result {
|
||||
case let .chats(apiChats):
|
||||
case let .chats(chatsData):
|
||||
let apiChats = chatsData.chats
|
||||
chats = apiChats
|
||||
case let .chatsSlice(_, apiChats):
|
||||
case let .chatsSlice(chatsSliceData):
|
||||
let (_, apiChats) = (chatsSliceData.count, chatsSliceData.chats)
|
||||
chats = apiChats
|
||||
}
|
||||
guard let id = chats.first?.peerId else {
|
||||
|
|
|
|||
|
|
@ -108,10 +108,12 @@ private final class GroupsInCommonContextImpl {
|
|||
let count: Int?
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .chats(apiChats):
|
||||
case let .chats(chatsData):
|
||||
let apiChats = chatsData.chats
|
||||
chats = apiChats
|
||||
count = nil
|
||||
case let .chatsSlice(apiCount, apiChats):
|
||||
case let .chatsSlice(chatsSliceData):
|
||||
let (apiCount, apiChats) = (chatsSliceData.count, chatsSliceData.chats)
|
||||
chats = apiChats
|
||||
count = Int(apiCount)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,7 +147,8 @@ func _internal_editPeerExportedInvitation(account: Account, peerId: PeerId, link
|
|||
|> mapError { _ in return EditPeerExportedInvitationError.generic }
|
||||
|> mapToSignal { result -> Signal<ExportedInvitation?, EditPeerExportedInvitationError> in
|
||||
return account.postbox.transaction { transaction in
|
||||
if case let .exportedChatInvite(invite, users) = result {
|
||||
if case let .exportedChatInvite(exportedChatInviteData) = result {
|
||||
let (invite, users) = (exportedChatInviteData.invite, exportedChatInviteData.users)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users))
|
||||
return ExportedInvitation(apiExportedInvite: invite)
|
||||
} else {
|
||||
|
|
@ -181,10 +182,12 @@ func _internal_revokePeerExportedInvitation(account: Account, peerId: PeerId, li
|
|||
|> mapError { _ in return RevokePeerExportedInvitationError.generic }
|
||||
|> mapToSignal { result -> Signal<RevokeExportedInvitationResult?, RevokePeerExportedInvitationError> in
|
||||
return account.postbox.transaction { transaction in
|
||||
if case let .exportedChatInvite(invite, users) = result {
|
||||
if case let .exportedChatInvite(exportedChatInviteData) = result {
|
||||
let (invite, users) = (exportedChatInviteData.invite, exportedChatInviteData.users)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users))
|
||||
return .update(ExportedInvitation(apiExportedInvite: invite))
|
||||
} else if case let .exportedChatInviteReplaced(invite, newInvite, users) = result {
|
||||
} else if case let .exportedChatInviteReplaced(exportedChatInviteReplacedData) = result {
|
||||
let (invite, newInvite, users) = (exportedChatInviteReplacedData.invite, exportedChatInviteReplacedData.newInvite, exportedChatInviteReplacedData.users)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users))
|
||||
|
||||
let previous = ExportedInvitation(apiExportedInvite: invite)
|
||||
|
|
@ -243,7 +246,8 @@ func _internal_peerExportedInvitations(account: Account, peerId: PeerId, revoked
|
|||
}
|
||||
|> mapToSignal { result -> Signal<ExportedInvitations?, NoError> in
|
||||
return account.postbox.transaction { transaction -> ExportedInvitations? in
|
||||
if let result = result, case let .exportedChatInvites(count, apiInvites, users) = result {
|
||||
if let result = result, case let .exportedChatInvites(exportedChatInvitesData) = result {
|
||||
let (count, apiInvites, users) = (exportedChatInvitesData.count, exportedChatInvitesData.invites, exportedChatInvitesData.users)
|
||||
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: [], users: users)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
|
||||
|
||||
|
|
@ -465,7 +469,8 @@ private final class PeerExportedInvitationsContextImpl {
|
|||
return ([], 0)
|
||||
}
|
||||
switch result {
|
||||
case let .exportedChatInvites(count, invites, users):
|
||||
case let .exportedChatInvites(exportedChatInvitesData):
|
||||
let (count, invites, users) = (exportedChatInvitesData.count, exportedChatInvitesData.invites, exportedChatInvitesData.users)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users))
|
||||
let invitations: [ExportedInvitation] = invites.compactMap { ExportedInvitation(apiExportedInvite: $0) }
|
||||
if populateCache {
|
||||
|
|
@ -948,7 +953,8 @@ private final class PeerInvitationImportersContextImpl {
|
|||
return ([], 0)
|
||||
}
|
||||
switch result {
|
||||
case let .chatInviteImporters(count, importers, users):
|
||||
case let .chatInviteImporters(chatInviteImportersData):
|
||||
let (count, importers, users) = (chatInviteImportersData.count, chatInviteImportersData.importers, chatInviteImportersData.users)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users))
|
||||
var resultImporters: [PeerInvitationImportersState.Importer] = []
|
||||
for importer in importers {
|
||||
|
|
@ -1162,7 +1168,8 @@ func _internal_peerExportedInvitationsCreators(account: Account, peerId: PeerId)
|
|||
}
|
||||
|> mapToSignal { result -> Signal<[ExportedInvitationCreator], NoError> in
|
||||
return account.postbox.transaction { transaction -> [ExportedInvitationCreator] in
|
||||
if let result = result, case let .chatAdminsWithInvites(admins, users) = result {
|
||||
if let result = result, case let .chatAdminsWithInvites(chatAdminsWithInvitesData) = result {
|
||||
let (admins, users) = (chatAdminsWithInvitesData.admins, chatAdminsWithInvitesData.users)
|
||||
var creators: [ExportedInvitationCreator] = []
|
||||
|
||||
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: [], users: users)
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ func _internal_availableGroupsForChannelDiscussion(accountPeerId: PeerId, postbo
|
|||
|> mapToSignal { result -> Signal<[Peer], AvailableChannelDiscussionGroupError> in
|
||||
let chats: [Api.Chat]
|
||||
switch result {
|
||||
case let .chats(c):
|
||||
case let .chats(chatsData):
|
||||
let c = chatsData.chats
|
||||
chats = c
|
||||
case let .chatsSlice(_, c):
|
||||
case let .chatsSlice(chatsSliceData):
|
||||
let c = chatsSliceData.chats
|
||||
chats = c
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -493,7 +493,8 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee
|
|||
}
|
||||
return postbox.transaction { transaction -> Bool in
|
||||
switch result {
|
||||
case let .chatFull(fullChat, chats, users):
|
||||
case let .chatFull(messagesChatFullData):
|
||||
let (fullChat, chats, users) = (messagesChatFullData.fullChat, messagesChatFullData.chats, messagesChatFullData.users)
|
||||
switch fullChat {
|
||||
case let .chatFull(chatFullData):
|
||||
let (notifySettings) = (chatFullData.notifySettings)
|
||||
|
|
@ -641,7 +642,8 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee
|
|||
return postbox.transaction { transaction -> Bool in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .chatFull(fullChat, chats, users):
|
||||
case let .chatFull(messagesChatFullData):
|
||||
let (fullChat, chats, users) = (messagesChatFullData.fullChat, messagesChatFullData.chats, messagesChatFullData.users)
|
||||
switch fullChat {
|
||||
case let .channelFull(channelFullData):
|
||||
let notifySettings = channelFullData.notifySettings
|
||||
|
|
|
|||
|
|
@ -300,18 +300,19 @@ func _internal_searchStickers(account: Account, query: String?, emoticon: [Strin
|
|||
let flags: Int32 = 0
|
||||
remote = account.network.request(Api.functions.messages.searchStickers(flags: flags, q: query, emoticon: emoticon.joined(separator: ""), langCode: [inputLanguageCode], offset: 0, limit: 128, hash: cached?.hash ?? 0))
|
||||
|> `catch` { _ -> Signal<Api.messages.FoundStickers, NoError> in
|
||||
return .single(.foundStickersNotModified(flags: 0, nextOffset: nil))
|
||||
return .single(.foundStickersNotModified(.init(flags: 0, nextOffset: nil)))
|
||||
}
|
||||
|> mapToSignal { result -> Signal<(items: [FoundStickerItem], isFinalResult: Bool), NoError> in
|
||||
return account.postbox.transaction { transaction -> (items: [FoundStickerItem], isFinalResult: Bool) in
|
||||
switch result {
|
||||
case let .foundStickers(_, _, hash, stickers):
|
||||
case let .foundStickers(foundStickersData):
|
||||
let (_, _, hash, stickers) = (foundStickersData.flags, foundStickersData.nextOffset, foundStickersData.hash, foundStickersData.stickers)
|
||||
var result: [FoundStickerItem] = []
|
||||
let currentItemIds = Set<MediaId>(localItems.map { $0.file.fileId })
|
||||
|
||||
|
||||
var premiumItems: [FoundStickerItem] = []
|
||||
var otherItems: [FoundStickerItem] = []
|
||||
|
||||
|
||||
for item in localItems {
|
||||
if item.file.isPremiumSticker {
|
||||
premiumItems.append(item)
|
||||
|
|
@ -319,11 +320,11 @@ func _internal_searchStickers(account: Account, query: String?, emoticon: [Strin
|
|||
otherItems.append(item)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var foundItems: [FoundStickerItem] = []
|
||||
var foundAnimatedItems: [FoundStickerItem] = []
|
||||
var foundPremiumItems: [FoundStickerItem] = []
|
||||
|
||||
|
||||
var files: [TelegramMediaFile] = []
|
||||
for sticker in stickers {
|
||||
if let file = telegramMediaFileFromApiDocument(sticker, altDocuments: []), let id = file.id {
|
||||
|
|
@ -339,10 +340,10 @@ func _internal_searchStickers(account: Account, query: String?, emoticon: [Strin
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let allPremiumItems = premiumItems + foundPremiumItems
|
||||
let allOtherItems = otherItems + foundAnimatedItems + foundItems
|
||||
|
||||
|
||||
if isPremium {
|
||||
let batchCount = Int(searchStickersConfiguration.normalStickersPerPremiumCount)
|
||||
if batchCount == 0 {
|
||||
|
|
@ -373,12 +374,12 @@ func _internal_searchStickers(account: Account, query: String?, emoticon: [Strin
|
|||
result.append(contentsOf: allOtherItems)
|
||||
result.append(contentsOf: allPremiumItems.prefix(max(0, Int(searchStickersConfiguration.premiumStickersCount))))
|
||||
}
|
||||
|
||||
|
||||
let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
|
||||
if hash != 0, let entry = CodableEntry(CachedStickerQueryResult(items: files, hash: hash, timestamp: currentTime)) {
|
||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerQueryResults, key: CachedStickerQueryResult.cacheKey(cacheKey)), entry: entry)
|
||||
}
|
||||
|
||||
|
||||
return (result, true)
|
||||
case .foundStickersNotModified:
|
||||
break
|
||||
|
|
@ -953,12 +954,13 @@ func _internal_searchEmoji(account: Account, query: String?, emoticon: [String],
|
|||
let flags: Int32 = 1 << 0
|
||||
remote = account.network.request(Api.functions.messages.searchStickers(flags: flags, q: query, emoticon: emoticon.joined(separator: ""), langCode: [inputLanguageCode], offset: 0, limit: 128, hash: cached?.hash ?? 0))
|
||||
|> `catch` { _ -> Signal<Api.messages.FoundStickers, NoError> in
|
||||
return .single(.foundStickersNotModified(flags: 0, nextOffset: nil))
|
||||
return .single(.foundStickersNotModified(.init(flags: 0, nextOffset: nil)))
|
||||
}
|
||||
|> mapToSignal { result -> Signal<(items: [FoundStickerItem], isFinalResult: Bool), NoError> in
|
||||
return account.postbox.transaction { transaction -> (items: [FoundStickerItem], isFinalResult: Bool) in
|
||||
switch result {
|
||||
case let .foundStickers(_, _, hash, stickers):
|
||||
case let .foundStickers(foundStickersData):
|
||||
let (_, _, hash, stickers) = (foundStickersData.flags, foundStickersData.nextOffset, foundStickersData.hash, foundStickersData.stickers)
|
||||
var result: [FoundStickerItem] = localItems
|
||||
var currentItemIds = Set<MediaId>(localItems.map { $0.file.fileId })
|
||||
|
||||
|
|
@ -973,12 +975,12 @@ func _internal_searchEmoji(account: Account, query: String?, emoticon: [String],
|
|||
result.append(FoundStickerItem(file: file, stringRepresentations: []))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
|
||||
if let entry = CodableEntry(CachedStickerQueryResult(items: files, hash: hash, timestamp: currentTime)) {
|
||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedEmojiQueryResults, key: CachedStickerQueryResult.cacheKey(cacheKey)), entry: entry)
|
||||
}
|
||||
|
||||
|
||||
return (result, true)
|
||||
case .foundStickersNotModified:
|
||||
break
|
||||
|
|
@ -1069,7 +1071,8 @@ func _internal_searchStickerSetsRemotely(network: Network, query: String) -> Sig
|
|||
|> mapToSignal { value in
|
||||
var index: Int32 = 1000
|
||||
switch value {
|
||||
case let .foundStickerSets(_, sets: sets):
|
||||
case let .foundStickerSets(foundStickerSetsData):
|
||||
let (_, sets) = (foundStickerSetsData.hash, foundStickerSetsData.sets)
|
||||
var result = FoundStickerSets()
|
||||
for set in sets {
|
||||
let parsed = parsePreviewStickerSet(set, namespace: Namespaces.ItemCollection.CloudStickerPacks)
|
||||
|
|
@ -1081,7 +1084,7 @@ func _internal_searchStickerSetsRemotely(network: Network, query: String) -> Sig
|
|||
default:
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
return .complete()
|
||||
}
|
||||
|> `catch` { _ -> Signal<FoundStickerSets, NoError> in
|
||||
|
|
@ -1095,7 +1098,8 @@ func _internal_searchEmojiSetsRemotely(postbox: Postbox, network: Network, query
|
|||
|> mapToSignal { value in
|
||||
var index: Int32 = 1000
|
||||
switch value {
|
||||
case let .foundStickerSets(_, sets: sets):
|
||||
case let .foundStickerSets(foundStickerSetsData):
|
||||
let (_, sets) = (foundStickerSetsData.hash, foundStickerSetsData.sets)
|
||||
var result = FoundStickerSets()
|
||||
for set in sets {
|
||||
let parsed = parsePreviewStickerSet(set, namespace: Namespaces.ItemCollection.CloudEmojiPacks)
|
||||
|
|
@ -1107,7 +1111,7 @@ func _internal_searchEmojiSetsRemotely(postbox: Postbox, network: Network, query
|
|||
default:
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
return .complete()
|
||||
}
|
||||
|> `catch` { _ -> Signal<FoundStickerSets, NoError> in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue