Files
Swiftgram/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdateGroupSpecificStickerset.swift
Isaac e68bdc05ca Refactor Api types 150-179 to use struct-wrapped constructors
- Update pattern matches to use struct-based extraction for inputPeer*,
  inputMedia*, inputReplyTo*, inputSticker*, inputPhoto, inputUser, etc.
- Wrap constructor calls with .init() for struct-wrapped enum cases
- 47 TelegramCore source files modified
- 5 TelegramApi files regenerated with --struct-count=180

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 15:18:11 +08:00

81 lines
3.5 KiB
Swift

import Foundation
import Postbox
import TelegramApi
import SwiftSignalKit
public enum UpdateGroupSpecificStickersetError {
case generic
}
func _internal_updateGroupSpecificStickerset(postbox: Postbox, network: Network, peerId: PeerId, info: StickerPackCollectionInfo?) -> Signal<Void, UpdateGroupSpecificStickersetError> {
return postbox.loadedPeerWithId(peerId)
|> castError(UpdateGroupSpecificStickersetError.self)
|> mapToSignal { peer -> Signal<Void, UpdateGroupSpecificStickersetError> in
let inputStickerset: Api.InputStickerSet
if let info = info {
inputStickerset = Api.InputStickerSet.inputStickerSetShortName(.init(shortName: info.shortName))
} else {
inputStickerset = Api.InputStickerSet.inputStickerSetEmpty
}
if let inputChannel = apiInputChannel(peer) {
return network.request(Api.functions.channels.setStickers(channel: inputChannel, stickerset: inputStickerset))
|> mapError { _ -> UpdateGroupSpecificStickersetError in
return .generic
}
|> mapToSignal { value -> Signal<Void, UpdateGroupSpecificStickersetError> in
switch value {
case .boolTrue:
return postbox.transaction { transaction -> Void in
return transaction.updatePeerCachedData(peerIds: [peerId], update: { _, current -> CachedPeerData? in
return (current as? CachedChannelData)?.withUpdatedStickerPack(info)
})
}
|> castError(UpdateGroupSpecificStickersetError.self)
default:
return .complete()
}
}
}
return .complete()
}
}
public enum UpdateGroupSpecificEmojisetError {
case generic
}
func _internal_updateGroupSpecificEmojiset(postbox: Postbox, network: Network, peerId: PeerId, info: StickerPackCollectionInfo?) -> Signal<Void, UpdateGroupSpecificEmojisetError> {
return postbox.loadedPeerWithId(peerId)
|> castError(UpdateGroupSpecificEmojisetError.self)
|> mapToSignal { peer -> Signal<Void, UpdateGroupSpecificEmojisetError> in
let inputStickerset: Api.InputStickerSet
if let info = info {
inputStickerset = Api.InputStickerSet.inputStickerSetShortName(.init(shortName: info.shortName))
} else {
inputStickerset = Api.InputStickerSet.inputStickerSetEmpty
}
if let inputChannel = apiInputChannel(peer) {
return network.request(Api.functions.channels.setEmojiStickers(channel: inputChannel, stickerset: inputStickerset))
|> mapError { _ -> UpdateGroupSpecificEmojisetError in
return .generic
}
|> mapToSignal { value -> Signal<Void, UpdateGroupSpecificEmojisetError> in
switch value {
case .boolTrue:
return postbox.transaction { transaction -> Void in
return transaction.updatePeerCachedData(peerIds: [peerId], update: { _, current -> CachedPeerData? in
return (current as? CachedChannelData)?.withUpdatedEmojiPack(info)
})
}
|> castError(UpdateGroupSpecificEmojisetError.self)
default:
return .complete()
}
}
}
return .complete()
}
}