Update API

This commit is contained in:
Ilya Laktyushin 2025-11-10 20:26:02 +04:00
parent ea8dc07b23
commit aba2704dcb
4 changed files with 62 additions and 79 deletions

View file

@ -990,7 +990,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1571835723] = { return Api.StarGiftAuctionState.parse_starGiftAuctionState($0) }
dict[2107014202] = { return Api.StarGiftAuctionState.parse_starGiftAuctionStateFinished($0) }
dict[-30197422] = { return Api.StarGiftAuctionState.parse_starGiftAuctionStateNotModified($0) }
dict[-165829476] = { return Api.StarGiftAuctionUserState.parse_starGiftAuctionUserState($0) }
dict[787403204] = { return Api.StarGiftAuctionUserState.parse_starGiftAuctionUserState($0) }
dict[-1653926992] = { return Api.StarGiftCollection.parse_starGiftCollection($0) }
dict[-1712704739] = { return Api.StarGiftUpgradePrice.parse_starGiftUpgradePrice($0) }
dict[-586389774] = { return Api.StarRefProgram.parse_starRefProgram($0) }

View file

@ -1036,18 +1036,19 @@ public extension Api {
}
public extension Api {
enum StarGiftAuctionUserState: TypeConstructorDescription {
case starGiftAuctionUserState(flags: Int32, bidAmount: Int64?, bidDate: Int32?, minBidAmount: Int64?, acquiredCount: Int32)
case starGiftAuctionUserState(flags: Int32, bidAmount: Int64?, bidDate: Int32?, minBidAmount: Int64?, bidPeer: Api.Peer?, acquiredCount: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starGiftAuctionUserState(let flags, let bidAmount, let bidDate, let minBidAmount, let acquiredCount):
case .starGiftAuctionUserState(let flags, let bidAmount, let bidDate, let minBidAmount, let bidPeer, let acquiredCount):
if boxed {
buffer.appendInt32(-165829476)
buffer.appendInt32(787403204)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt64(bidAmount!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(bidDate!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 0) != 0 {serializeInt64(minBidAmount!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 0) != 0 {bidPeer!.serialize(buffer, true)}
serializeInt32(acquiredCount, buffer: buffer, boxed: false)
break
}
@ -1055,8 +1056,8 @@ public extension Api {
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starGiftAuctionUserState(let flags, let bidAmount, let bidDate, let minBidAmount, let acquiredCount):
return ("starGiftAuctionUserState", [("flags", flags as Any), ("bidAmount", bidAmount as Any), ("bidDate", bidDate as Any), ("minBidAmount", minBidAmount as Any), ("acquiredCount", acquiredCount as Any)])
case .starGiftAuctionUserState(let flags, let bidAmount, let bidDate, let minBidAmount, let bidPeer, let acquiredCount):
return ("starGiftAuctionUserState", [("flags", flags as Any), ("bidAmount", bidAmount as Any), ("bidDate", bidDate as Any), ("minBidAmount", minBidAmount as Any), ("bidPeer", bidPeer as Any), ("acquiredCount", acquiredCount as Any)])
}
}
@ -1069,15 +1070,20 @@ public extension Api {
if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt32() }
var _4: Int64?
if Int(_1!) & Int(1 << 0) != 0 {_4 = reader.readInt64() }
var _5: Int32?
_5 = reader.readInt32()
var _5: Api.Peer?
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.Peer
} }
var _6: Int32?
_6 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
let _c5 = _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.StarGiftAuctionUserState.starGiftAuctionUserState(flags: _1!, bidAmount: _2, bidDate: _3, minBidAmount: _4, acquiredCount: _5!)
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
let _c6 = _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.StarGiftAuctionUserState.starGiftAuctionUserState(flags: _1!, bidAmount: _2, bidDate: _3, minBidAmount: _4, bidPeer: _5, acquiredCount: _6!)
}
else {
return nil

View file

@ -64,6 +64,7 @@ public final class GiftAuctionContext {
public var bidAmount: Int64?
public var bidDate: Int32?
public var minBidAmount: Int64?
public var bidPeerId: EnginePeer.Id?
public var acquiredCount: Int32
}
@ -203,11 +204,12 @@ extension GiftAuctionContext.State.AuctionState {
extension GiftAuctionContext.State.MyState {
init(apiAuctionUserState: Api.StarGiftAuctionUserState) {
switch apiAuctionUserState {
case let .starGiftAuctionUserState(flags, bidAmount, bidDate, minBidAmount, acquiredCount):
case let .starGiftAuctionUserState(flags, bidAmount, bidDate, minBidAmount, bidPeerId, acquiredCount):
self.isOutbid = (flags & (1 << 1)) != 0
self.bidAmount = bidAmount
self.bidDate = bidDate
self.minBidAmount = minBidAmount
self.bidPeerId = bidPeerId?.peerId
self.acquiredCount = acquiredCount
}
}

View file

@ -746,39 +746,6 @@ final class LiveStreamSettingsScreenComponent: Component {
action: nil
))))
// var pinTitle = "Post to My Profile"
// var pinInfo = "Keep this live on your profile."
// if screenState.sendAsPeerId?.namespace == Namespaces.Peer.CloudChannel {
// pinTitle = "Post to Channel Profile"
// pinInfo = "Keep this live on channel profile."
// }
//
// settingsSectionItems.append(AnyComponentWithIdentity(id: "pin", component: AnyComponent(ListActionItemComponent(
// theme: theme,
// style: .glass,
// title: AnyComponent(MultilineTextComponent(
// text: .plain(NSAttributedString(
// string: pinTitle,
// font: Font.regular(presentationData.listsFontSize.baseDisplaySize),
// textColor: theme.list.itemPrimaryTextColor
// )),
// maximumNumberOfLines: 1
// )),
// accessory: .toggle(ListActionItemComponent.Toggle(style: .regular, isOn: screenState.pin, action: { [weak self] _ in
// guard let self else {
// return
// }
// component.stateContext.pin = !component.stateContext.pin
// self.state?.updated(transition: .spring(duration: 0.4))
// })),
// action: nil
// ))))
//
// let settingsSectionFooterComponent = AnyComponent(MultilineTextComponent(
// text: .plain(NSAttributedString(string: pinInfo, font: footerTextFont, textColor: footerTextColor)),
// maximumNumberOfLines: 0
// ))
let settingsSectionSize = self.settingsSection.update(
transition: transition,
component: AnyComponent(ListSectionComponent(
@ -810,7 +777,7 @@ final class LiveStreamSettingsScreenComponent: Component {
minValue: 0,
lowerBoundTitle: "0",
upperBoundTitle: "\(presentationStringsFormattedNumber(Int32(clamping: screenState.maxPaidMessageStars), environment.dateTimeFormat.groupingSeparator))",
title: "\(screenState.paidMessageStars) Stars",
title: screenState.paidMessageStars == 0 ? "Free" : "\(screenState.paidMessageStars) Stars",
valueUpdated: { [weak self] value in
guard let self, let component = self.component else {
return
@ -823,41 +790,49 @@ final class LiveStreamSettingsScreenComponent: Component {
)
))]
let paidMessageSectionHeader = AnyComponent(MultilineTextComponent(
text: .plain(NSAttributedString(
string: "PRICE PER COMMENT",
font: Font.regular(presentationData.listsFontSize.itemListBaseHeaderFontSize),
textColor: theme.list.freeTextColor
)),
maximumNumberOfLines: 0
))
let paidMessageSectionFooterComponent = AnyComponent(MultilineTextComponent(
text: .plain(NSAttributedString(string: "The price a viewer must pay to send a comment.", font: footerTextFont, textColor: footerTextColor)),
maximumNumberOfLines: 0
))
let paidMessageSectionSize = self.paidMessageSection.update(
transition: transition,
component: AnyComponent(ListSectionComponent(
theme: theme,
style: .glass,
header: paidMessageSectionHeader,
footer: paidMessageSectionFooterComponent,
items: paidMessageSectionItems
)),
environment: {},
containerSize: CGSize(width: availableSize.width - sideInset * 2.0, height: 10000.0)
)
let paidMessageSectionFrame = CGRect(origin: CGPoint(x: sideInset, y: contentHeight), size: paidMessageSectionSize)
if let paidMessageSectionView = self.paidMessageSection.view as? ListSectionComponent.View {
if paidMessageSectionView.superview == nil {
self.scrollView.addSubview(paidMessageSectionView)
self.paidMessageSection.parentState = state
if screenState.allowComments {
let paidMessageSectionHeader = AnyComponent(MultilineTextComponent(
text: .plain(NSAttributedString(
string: "PRICE PER COMMENT",
font: Font.regular(presentationData.listsFontSize.itemListBaseHeaderFontSize),
textColor: theme.list.freeTextColor
)),
maximumNumberOfLines: 0
))
let paidMessageSectionFooterComponent = AnyComponent(MultilineTextComponent(
text: .plain(NSAttributedString(string: "The price a viewer must pay to send a comment.", font: footerTextFont, textColor: footerTextColor)),
maximumNumberOfLines: 0
))
let paidMessageSectionSize = self.paidMessageSection.update(
transition: transition,
component: AnyComponent(ListSectionComponent(
theme: theme,
style: .glass,
header: paidMessageSectionHeader,
footer: paidMessageSectionFooterComponent,
items: paidMessageSectionItems
)),
environment: {},
containerSize: CGSize(width: availableSize.width - sideInset * 2.0, height: 10000.0)
)
let paidMessageSectionFrame = CGRect(origin: CGPoint(x: sideInset, y: contentHeight), size: paidMessageSectionSize)
if let paidMessageSectionView = self.paidMessageSection.view as? ListSectionComponent.View {
if paidMessageSectionView.superview == nil {
paidMessageSectionView.alpha = 1.0
self.scrollView.addSubview(paidMessageSectionView)
self.paidMessageSection.parentState = state
transition.animateAlpha(view: paidMessageSectionView, from: 0.0, to: 1.0)
}
transition.setFrame(view: paidMessageSectionView, frame: paidMessageSectionFrame)
}
transition.setFrame(view: paidMessageSectionView, frame: paidMessageSectionFrame)
contentHeight += paidMessageSectionSize.height
} else if let paidMessageSectionView = self.paidMessageSection.view {
transition.setAlpha(view: paidMessageSectionView, alpha: 0.0, completion: { _ in
paidMessageSectionView.removeFromSuperview()
})
}
contentHeight += paidMessageSectionSize.height
let edgeEffectHeight: CGFloat = 80.0
let edgeEffectFrame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: availableSize.width, height: edgeEffectHeight))