Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Mikhail Filimonov 2025-12-02 14:29:35 +04:00
commit e2b49cc712
18 changed files with 402 additions and 285 deletions

View file

@ -15489,6 +15489,9 @@ Error: %8$@";
"Gift.Auction.StartsInHours" = "auction starts in {h}:{m}:{s}";
"Gift.Auction.StartsInMinutes" = "auction starts in {m}:{s}";
"Gift.Auction.EarlyBid" = "Place an Early Bid";
"Gift.Auction.ViewVariants" = "View";
"Gift.Auction.Variants_1" = "%@ Variant";
"Gift.Auction.Variants_any" = "%@ Variants";
"Gift.Auction.Hours_1" = "%@ hour";
"Gift.Auction.Hours_any" = "%@ hours";

View file

@ -1429,6 +1429,7 @@ public protocol SharedAccountContext: AnyObject {
func makeGiftAuctionViewScreen(context: AccountContext, auctionContext: GiftAuctionContext, completion: @escaping (Signal<[GiftAuctionAcquiredGift], NoError>) -> Void) -> ViewController
func makeGiftAuctionActiveBidsScreen(context: AccountContext) -> ViewController
func makeGiftOfferScreen(context: AccountContext, gift: StarGift.UniqueGift, peer: EnginePeer, amount: CurrencyAmount, commit: @escaping () -> Void) -> ViewController
func makeGiftUpgradeVariantsPreviewScreen(context: AccountContext, gift: StarGift, attributes: [StarGift.UniqueGift.Attribute]) -> ViewController
func makeStorySharingScreen(context: AccountContext, subject: StorySharingSubject, parentController: ViewController) -> ViewController

View file

@ -980,7 +980,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[2109703795] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) }
dict[-963180333] = { return Api.SponsoredPeer.parse_sponsoredPeer($0) }
dict[1453798502] = { return Api.StarGift.parse_starGift($0) }
dict[825922887] = { return Api.StarGift.parse_starGift($0) }
dict[1453155529] = { return Api.StarGift.parse_starGiftUnique($0) }
dict[-753154979] = { return Api.StarGiftActiveAuctionState.parse_starGiftActiveAuctionState($0) }
dict[-650279524] = { return Api.StarGiftAttribute.parse_starGiftAttributeBackdrop($0) }
@ -995,9 +995,10 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[984483112] = { return Api.StarGiftAuctionRound.parse_starGiftAuctionRound($0) }
dict[178266597] = { return Api.StarGiftAuctionRound.parse_starGiftAuctionRoundExtendable($0) }
dict[1998212710] = { return Api.StarGiftAuctionState.parse_starGiftAuctionState($0) }
dict[2107014202] = { return Api.StarGiftAuctionState.parse_starGiftAuctionStateFinished($0) }
dict[-1758614593] = { return Api.StarGiftAuctionState.parse_starGiftAuctionStateFinished($0) }
dict[-30197422] = { return Api.StarGiftAuctionState.parse_starGiftAuctionStateNotModified($0) }
dict[787403204] = { return Api.StarGiftAuctionUserState.parse_starGiftAuctionUserState($0) }
dict[-1342872680] = { return Api.StarGiftBackground.parse_starGiftBackground($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) }
@ -1254,7 +1255,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[555358088] = { return Api.WebPage.parse_webPageEmpty($0) }
dict[1930545681] = { return Api.WebPage.parse_webPageNotModified($0) }
dict[-1328464313] = { return Api.WebPage.parse_webPagePending($0) }
dict[55150251] = { return Api.WebPageAttribute.parse_webPageAttributeStarGiftAuction($0) }
dict[29770178] = { return Api.WebPageAttribute.parse_webPageAttributeStarGiftAuction($0) }
dict[835375875] = { return Api.WebPageAttribute.parse_webPageAttributeStarGiftCollection($0) }
dict[1355547603] = { return Api.WebPageAttribute.parse_webPageAttributeStickerSet($0) }
dict[781501415] = { return Api.WebPageAttribute.parse_webPageAttributeStory($0) }
@ -2252,6 +2253,8 @@ public extension Api {
_1.serialize(buffer, boxed)
case let _1 as Api.StarGiftAuctionUserState:
_1.serialize(buffer, boxed)
case let _1 as Api.StarGiftBackground:
_1.serialize(buffer, boxed)
case let _1 as Api.StarGiftCollection:
_1.serialize(buffer, boxed)
case let _1 as Api.StarGiftUpgradePrice:

View file

@ -288,14 +288,14 @@ public extension Api {
}
public extension Api {
enum StarGift: TypeConstructorDescription {
case starGift(flags: Int32, id: Int64, sticker: Api.Document, stars: Int64, availabilityRemains: Int32?, availabilityTotal: Int32?, availabilityResale: Int64?, convertStars: Int64, firstSaleDate: Int32?, lastSaleDate: Int32?, upgradeStars: Int64?, resellMinStars: Int64?, title: String?, releasedBy: Api.Peer?, perUserTotal: Int32?, perUserRemains: Int32?, lockedUntilDate: Int32?, auctionSlug: String?, giftsPerRound: Int32?, auctionStartDate: Int32?, upgradeVariants: Int32?)
case starGift(flags: Int32, id: Int64, sticker: Api.Document, stars: Int64, availabilityRemains: Int32?, availabilityTotal: Int32?, availabilityResale: Int64?, convertStars: Int64, firstSaleDate: Int32?, lastSaleDate: Int32?, upgradeStars: Int64?, resellMinStars: Int64?, title: String?, releasedBy: Api.Peer?, perUserTotal: Int32?, perUserRemains: Int32?, lockedUntilDate: Int32?, auctionSlug: String?, giftsPerRound: Int32?, auctionStartDate: Int32?, upgradeVariants: Int32?, background: Api.StarGiftBackground?)
case starGiftUnique(flags: Int32, id: Int64, giftId: Int64, title: String, slug: String, num: Int32, ownerId: Api.Peer?, ownerName: String?, ownerAddress: String?, attributes: [Api.StarGiftAttribute], availabilityIssued: Int32, availabilityTotal: Int32, giftAddress: String?, resellAmount: [Api.StarsAmount]?, releasedBy: Api.Peer?, valueAmount: Int64?, valueCurrency: String?, valueUsdAmount: Int64?, themePeer: Api.Peer?, peerColor: Api.PeerColor?, hostId: Api.Peer?, offerMinStars: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let availabilityResale, let convertStars, let firstSaleDate, let lastSaleDate, let upgradeStars, let resellMinStars, let title, let releasedBy, let perUserTotal, let perUserRemains, let lockedUntilDate, let auctionSlug, let giftsPerRound, let auctionStartDate, let upgradeVariants):
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let availabilityResale, let convertStars, let firstSaleDate, let lastSaleDate, let upgradeStars, let resellMinStars, let title, let releasedBy, let perUserTotal, let perUserRemains, let lockedUntilDate, let auctionSlug, let giftsPerRound, let auctionStartDate, let upgradeVariants, let background):
if boxed {
buffer.appendInt32(1453798502)
buffer.appendInt32(825922887)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(id, buffer: buffer, boxed: false)
@ -318,6 +318,7 @@ public extension Api {
if Int(flags) & Int(1 << 11) != 0 {serializeInt32(giftsPerRound!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 11) != 0 {serializeInt32(auctionStartDate!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 12) != 0 {serializeInt32(upgradeVariants!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 13) != 0 {background!.serialize(buffer, true)}
break
case .starGiftUnique(let flags, let id, let giftId, let title, let slug, let num, let ownerId, let ownerName, let ownerAddress, let attributes, let availabilityIssued, let availabilityTotal, let giftAddress, let resellAmount, let releasedBy, let valueAmount, let valueCurrency, let valueUsdAmount, let themePeer, let peerColor, let hostId, let offerMinStars):
if boxed {
@ -359,8 +360,8 @@ public extension Api {
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let availabilityResale, let convertStars, let firstSaleDate, let lastSaleDate, let upgradeStars, let resellMinStars, let title, let releasedBy, let perUserTotal, let perUserRemains, let lockedUntilDate, let auctionSlug, let giftsPerRound, let auctionStartDate, let upgradeVariants):
return ("starGift", [("flags", flags as Any), ("id", id as Any), ("sticker", sticker as Any), ("stars", stars as Any), ("availabilityRemains", availabilityRemains as Any), ("availabilityTotal", availabilityTotal as Any), ("availabilityResale", availabilityResale as Any), ("convertStars", convertStars as Any), ("firstSaleDate", firstSaleDate as Any), ("lastSaleDate", lastSaleDate as Any), ("upgradeStars", upgradeStars as Any), ("resellMinStars", resellMinStars as Any), ("title", title as Any), ("releasedBy", releasedBy as Any), ("perUserTotal", perUserTotal as Any), ("perUserRemains", perUserRemains as Any), ("lockedUntilDate", lockedUntilDate as Any), ("auctionSlug", auctionSlug as Any), ("giftsPerRound", giftsPerRound as Any), ("auctionStartDate", auctionStartDate as Any), ("upgradeVariants", upgradeVariants as Any)])
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let availabilityResale, let convertStars, let firstSaleDate, let lastSaleDate, let upgradeStars, let resellMinStars, let title, let releasedBy, let perUserTotal, let perUserRemains, let lockedUntilDate, let auctionSlug, let giftsPerRound, let auctionStartDate, let upgradeVariants, let background):
return ("starGift", [("flags", flags as Any), ("id", id as Any), ("sticker", sticker as Any), ("stars", stars as Any), ("availabilityRemains", availabilityRemains as Any), ("availabilityTotal", availabilityTotal as Any), ("availabilityResale", availabilityResale as Any), ("convertStars", convertStars as Any), ("firstSaleDate", firstSaleDate as Any), ("lastSaleDate", lastSaleDate as Any), ("upgradeStars", upgradeStars as Any), ("resellMinStars", resellMinStars as Any), ("title", title as Any), ("releasedBy", releasedBy as Any), ("perUserTotal", perUserTotal as Any), ("perUserRemains", perUserRemains as Any), ("lockedUntilDate", lockedUntilDate as Any), ("auctionSlug", auctionSlug as Any), ("giftsPerRound", giftsPerRound as Any), ("auctionStartDate", auctionStartDate as Any), ("upgradeVariants", upgradeVariants as Any), ("background", background as Any)])
case .starGiftUnique(let flags, let id, let giftId, let title, let slug, let num, let ownerId, let ownerName, let ownerAddress, let attributes, let availabilityIssued, let availabilityTotal, let giftAddress, let resellAmount, let releasedBy, let valueAmount, let valueCurrency, let valueUsdAmount, let themePeer, let peerColor, let hostId, let offerMinStars):
return ("starGiftUnique", [("flags", flags as Any), ("id", id as Any), ("giftId", giftId as Any), ("title", title as Any), ("slug", slug as Any), ("num", num as Any), ("ownerId", ownerId as Any), ("ownerName", ownerName as Any), ("ownerAddress", ownerAddress as Any), ("attributes", attributes as Any), ("availabilityIssued", availabilityIssued as Any), ("availabilityTotal", availabilityTotal as Any), ("giftAddress", giftAddress as Any), ("resellAmount", resellAmount as Any), ("releasedBy", releasedBy as Any), ("valueAmount", valueAmount as Any), ("valueCurrency", valueCurrency as Any), ("valueUsdAmount", valueUsdAmount as Any), ("themePeer", themePeer as Any), ("peerColor", peerColor as Any), ("hostId", hostId as Any), ("offerMinStars", offerMinStars as Any)])
}
@ -413,6 +414,10 @@ public extension Api {
if Int(_1!) & Int(1 << 11) != 0 {_20 = reader.readInt32() }
var _21: Int32?
if Int(_1!) & Int(1 << 12) != 0 {_21 = reader.readInt32() }
var _22: Api.StarGiftBackground?
if Int(_1!) & Int(1 << 13) != 0 {if let signature = reader.readInt32() {
_22 = Api.parse(reader, signature: signature) as? Api.StarGiftBackground
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
@ -434,8 +439,9 @@ public extension Api {
let _c19 = (Int(_1!) & Int(1 << 11) == 0) || _19 != nil
let _c20 = (Int(_1!) & Int(1 << 11) == 0) || _20 != nil
let _c21 = (Int(_1!) & Int(1 << 12) == 0) || _21 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 && _c20 && _c21 {
return Api.StarGift.starGift(flags: _1!, id: _2!, sticker: _3!, stars: _4!, availabilityRemains: _5, availabilityTotal: _6, availabilityResale: _7, convertStars: _8!, firstSaleDate: _9, lastSaleDate: _10, upgradeStars: _11, resellMinStars: _12, title: _13, releasedBy: _14, perUserTotal: _15, perUserRemains: _16, lockedUntilDate: _17, auctionSlug: _18, giftsPerRound: _19, auctionStartDate: _20, upgradeVariants: _21)
let _c22 = (Int(_1!) & Int(1 << 13) == 0) || _22 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 && _c20 && _c21 && _c22 {
return Api.StarGift.starGift(flags: _1!, id: _2!, sticker: _3!, stars: _4!, availabilityRemains: _5, availabilityTotal: _6, availabilityResale: _7, convertStars: _8!, firstSaleDate: _9, lastSaleDate: _10, upgradeStars: _11, resellMinStars: _12, title: _13, releasedBy: _14, perUserTotal: _15, perUserRemains: _16, lockedUntilDate: _17, auctionSlug: _18, giftsPerRound: _19, auctionStartDate: _20, upgradeVariants: _21, background: _22)
}
else {
return nil
@ -1005,7 +1011,7 @@ public extension Api {
public extension Api {
enum StarGiftAuctionState: TypeConstructorDescription {
case starGiftAuctionState(version: Int32, startDate: Int32, endDate: Int32, minBidAmount: Int64, bidLevels: [Api.AuctionBidLevel], topBidders: [Int64], nextRoundAt: Int32, lastGiftNum: Int32, giftsLeft: Int32, currentRound: Int32, totalRounds: Int32, rounds: [Api.StarGiftAuctionRound])
case starGiftAuctionStateFinished(startDate: Int32, endDate: Int32, averagePrice: Int64)
case starGiftAuctionStateFinished(flags: Int32, startDate: Int32, endDate: Int32, averagePrice: Int64, listedCount: Int32?, fragmentListedCount: Int32?, fragmentListedUrl: String?)
case starGiftAuctionStateNotModified
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -1039,13 +1045,17 @@ public extension Api {
item.serialize(buffer, true)
}
break
case .starGiftAuctionStateFinished(let startDate, let endDate, let averagePrice):
case .starGiftAuctionStateFinished(let flags, let startDate, let endDate, let averagePrice, let listedCount, let fragmentListedCount, let fragmentListedUrl):
if boxed {
buffer.appendInt32(2107014202)
buffer.appendInt32(-1758614593)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(startDate, buffer: buffer, boxed: false)
serializeInt32(endDate, buffer: buffer, boxed: false)
serializeInt64(averagePrice, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(listedCount!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(fragmentListedCount!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {serializeString(fragmentListedUrl!, buffer: buffer, boxed: false)}
break
case .starGiftAuctionStateNotModified:
if boxed {
@ -1060,8 +1070,8 @@ public extension Api {
switch self {
case .starGiftAuctionState(let version, let startDate, let endDate, let minBidAmount, let bidLevels, let topBidders, let nextRoundAt, let lastGiftNum, let giftsLeft, let currentRound, let totalRounds, let rounds):
return ("starGiftAuctionState", [("version", version as Any), ("startDate", startDate as Any), ("endDate", endDate as Any), ("minBidAmount", minBidAmount as Any), ("bidLevels", bidLevels as Any), ("topBidders", topBidders as Any), ("nextRoundAt", nextRoundAt as Any), ("lastGiftNum", lastGiftNum as Any), ("giftsLeft", giftsLeft as Any), ("currentRound", currentRound as Any), ("totalRounds", totalRounds as Any), ("rounds", rounds as Any)])
case .starGiftAuctionStateFinished(let startDate, let endDate, let averagePrice):
return ("starGiftAuctionStateFinished", [("startDate", startDate as Any), ("endDate", endDate as Any), ("averagePrice", averagePrice as Any)])
case .starGiftAuctionStateFinished(let flags, let startDate, let endDate, let averagePrice, let listedCount, let fragmentListedCount, let fragmentListedUrl):
return ("starGiftAuctionStateFinished", [("flags", flags as Any), ("startDate", startDate as Any), ("endDate", endDate as Any), ("averagePrice", averagePrice as Any), ("listedCount", listedCount as Any), ("fragmentListedCount", fragmentListedCount as Any), ("fragmentListedUrl", fragmentListedUrl as Any)])
case .starGiftAuctionStateNotModified:
return ("starGiftAuctionStateNotModified", [])
}
@ -1122,13 +1132,25 @@ public extension Api {
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int64?
_3 = reader.readInt64()
var _3: Int32?
_3 = reader.readInt32()
var _4: Int64?
_4 = reader.readInt64()
var _5: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt32() }
var _6: Int32?
if Int(_1!) & Int(1 << 1) != 0 {_6 = reader.readInt32() }
var _7: String?
if Int(_1!) & Int(1 << 1) != 0 {_7 = parseString(reader) }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.StarGiftAuctionState.starGiftAuctionStateFinished(startDate: _1!, endDate: _2!, averagePrice: _3!)
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
let _c6 = (Int(_1!) & Int(1 << 1) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 1) == 0) || _7 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.StarGiftAuctionState.starGiftAuctionStateFinished(flags: _1!, startDate: _2!, endDate: _3!, averagePrice: _4!, listedCount: _5, fragmentListedCount: _6, fragmentListedUrl: _7)
}
else {
return nil
@ -1198,6 +1220,50 @@ public extension Api {
}
}
public extension Api {
enum StarGiftBackground: TypeConstructorDescription {
case starGiftBackground(centerColor: Int32, edgeColor: Int32, textColor: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starGiftBackground(let centerColor, let edgeColor, let textColor):
if boxed {
buffer.appendInt32(-1342872680)
}
serializeInt32(centerColor, buffer: buffer, boxed: false)
serializeInt32(edgeColor, buffer: buffer, boxed: false)
serializeInt32(textColor, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starGiftBackground(let centerColor, let edgeColor, let textColor):
return ("starGiftBackground", [("centerColor", centerColor as Any), ("edgeColor", edgeColor as Any), ("textColor", textColor as Any)])
}
}
public static func parse_starGiftBackground(_ reader: BufferReader) -> StarGiftBackground? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.StarGiftBackground.starGiftBackground(centerColor: _1!, edgeColor: _2!, textColor: _3!)
}
else {
return nil
}
}
}
}
public extension Api {
enum StarGiftCollection: TypeConstructorDescription {
case starGiftCollection(flags: Int32, collectionId: Int32, title: String, icon: Api.Document?, giftsCount: Int32, hash: Int64)
@ -1576,55 +1642,3 @@ public extension Api {
}
}
public extension Api {
enum StarsRating: TypeConstructorDescription {
case starsRating(flags: Int32, level: Int32, currentLevelStars: Int64, stars: Int64, nextLevelStars: Int64?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starsRating(let flags, let level, let currentLevelStars, let stars, let nextLevelStars):
if boxed {
buffer.appendInt32(453922567)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(level, buffer: buffer, boxed: false)
serializeInt64(currentLevelStars, buffer: buffer, boxed: false)
serializeInt64(stars, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt64(nextLevelStars!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starsRating(let flags, let level, let currentLevelStars, let stars, let nextLevelStars):
return ("starsRating", [("flags", flags as Any), ("level", level as Any), ("currentLevelStars", currentLevelStars as Any), ("stars", stars as Any), ("nextLevelStars", nextLevelStars as Any)])
}
}
public static func parse_starsRating(_ reader: BufferReader) -> StarsRating? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int64?
_3 = reader.readInt64()
var _4: Int64?
_4 = reader.readInt64()
var _5: Int64?
if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt64() }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.StarsRating.starsRating(flags: _1!, level: _2!, currentLevelStars: _3!, stars: _4!, nextLevelStars: _5)
}
else {
return nil
}
}
}
}

View file

@ -1,3 +1,55 @@
public extension Api {
enum StarsRating: TypeConstructorDescription {
case starsRating(flags: Int32, level: Int32, currentLevelStars: Int64, stars: Int64, nextLevelStars: Int64?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starsRating(let flags, let level, let currentLevelStars, let stars, let nextLevelStars):
if boxed {
buffer.appendInt32(453922567)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(level, buffer: buffer, boxed: false)
serializeInt64(currentLevelStars, buffer: buffer, boxed: false)
serializeInt64(stars, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt64(nextLevelStars!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starsRating(let flags, let level, let currentLevelStars, let stars, let nextLevelStars):
return ("starsRating", [("flags", flags as Any), ("level", level as Any), ("currentLevelStars", currentLevelStars as Any), ("stars", stars as Any), ("nextLevelStars", nextLevelStars as Any)])
}
}
public static func parse_starsRating(_ reader: BufferReader) -> StarsRating? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int64?
_3 = reader.readInt64()
var _4: Int64?
_4 = reader.readInt64()
var _5: Int64?
if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt64() }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.StarsRating.starsRating(flags: _1!, level: _2!, currentLevelStars: _3!, stars: _4!, nextLevelStars: _5)
}
else {
return nil
}
}
}
}
public extension Api {
enum StarsRevenueStatus: TypeConstructorDescription {
case starsRevenueStatus(flags: Int32, currentBalance: Api.StarsAmount, availableBalance: Api.StarsAmount, overallRevenue: Api.StarsAmount, nextWithdrawalAt: Int32?)
@ -1236,59 +1288,3 @@ public extension Api {
}
}
public extension Api {
enum StoryAlbum: TypeConstructorDescription {
case storyAlbum(flags: Int32, albumId: Int32, title: String, iconPhoto: Api.Photo?, iconVideo: Api.Document?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .storyAlbum(let flags, let albumId, let title, let iconPhoto, let iconVideo):
if boxed {
buffer.appendInt32(-1826262950)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(albumId, buffer: buffer, boxed: false)
serializeString(title, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {iconPhoto!.serialize(buffer, true)}
if Int(flags) & Int(1 << 1) != 0 {iconVideo!.serialize(buffer, true)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .storyAlbum(let flags, let albumId, let title, let iconPhoto, let iconVideo):
return ("storyAlbum", [("flags", flags as Any), ("albumId", albumId as Any), ("title", title as Any), ("iconPhoto", iconPhoto as Any), ("iconVideo", iconVideo as Any)])
}
}
public static func parse_storyAlbum(_ reader: BufferReader) -> StoryAlbum? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: String?
_3 = parseString(reader)
var _4: Api.Photo?
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.Photo
} }
var _5: Api.Document?
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.Document
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.StoryAlbum.storyAlbum(flags: _1!, albumId: _2!, title: _3!, iconPhoto: _4, iconVideo: _5)
}
else {
return nil
}
}
}
}

View file

@ -1,3 +1,59 @@
public extension Api {
enum StoryAlbum: TypeConstructorDescription {
case storyAlbum(flags: Int32, albumId: Int32, title: String, iconPhoto: Api.Photo?, iconVideo: Api.Document?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .storyAlbum(let flags, let albumId, let title, let iconPhoto, let iconVideo):
if boxed {
buffer.appendInt32(-1826262950)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(albumId, buffer: buffer, boxed: false)
serializeString(title, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {iconPhoto!.serialize(buffer, true)}
if Int(flags) & Int(1 << 1) != 0 {iconVideo!.serialize(buffer, true)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .storyAlbum(let flags, let albumId, let title, let iconPhoto, let iconVideo):
return ("storyAlbum", [("flags", flags as Any), ("albumId", albumId as Any), ("title", title as Any), ("iconPhoto", iconPhoto as Any), ("iconVideo", iconVideo as Any)])
}
}
public static func parse_storyAlbum(_ reader: BufferReader) -> StoryAlbum? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: String?
_3 = parseString(reader)
var _4: Api.Photo?
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.Photo
} }
var _5: Api.Document?
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.Document
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.StoryAlbum.storyAlbum(flags: _1!, albumId: _2!, title: _3!, iconPhoto: _4, iconVideo: _5)
}
else {
return nil
}
}
}
}
public extension Api {
enum StoryFwdHeader: TypeConstructorDescription {
case storyFwdHeader(flags: Int32, from: Api.Peer?, fromName: String?, storyId: Int32?)

View file

@ -1,6 +1,6 @@
public extension Api {
indirect enum WebPageAttribute: TypeConstructorDescription {
case webPageAttributeStarGiftAuction(gift: Api.StarGift, endDate: Int32, centerColor: Int32, edgeColor: Int32, textColor: Int32)
case webPageAttributeStarGiftAuction(gift: Api.StarGift, endDate: Int32)
case webPageAttributeStarGiftCollection(icons: [Api.Document])
case webPageAttributeStickerSet(flags: Int32, stickers: [Api.Document])
case webPageAttributeStory(flags: Int32, peer: Api.Peer, id: Int32, story: Api.StoryItem?)
@ -9,15 +9,12 @@ public extension Api {
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .webPageAttributeStarGiftAuction(let gift, let endDate, let centerColor, let edgeColor, let textColor):
case .webPageAttributeStarGiftAuction(let gift, let endDate):
if boxed {
buffer.appendInt32(55150251)
buffer.appendInt32(29770178)
}
gift.serialize(buffer, true)
serializeInt32(endDate, buffer: buffer, boxed: false)
serializeInt32(centerColor, buffer: buffer, boxed: false)
serializeInt32(edgeColor, buffer: buffer, boxed: false)
serializeInt32(textColor, buffer: buffer, boxed: false)
break
case .webPageAttributeStarGiftCollection(let icons):
if boxed {
@ -72,8 +69,8 @@ public extension Api {
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .webPageAttributeStarGiftAuction(let gift, let endDate, let centerColor, let edgeColor, let textColor):
return ("webPageAttributeStarGiftAuction", [("gift", gift as Any), ("endDate", endDate as Any), ("centerColor", centerColor as Any), ("edgeColor", edgeColor as Any), ("textColor", textColor as Any)])
case .webPageAttributeStarGiftAuction(let gift, let endDate):
return ("webPageAttributeStarGiftAuction", [("gift", gift as Any), ("endDate", endDate as Any)])
case .webPageAttributeStarGiftCollection(let icons):
return ("webPageAttributeStarGiftCollection", [("icons", icons as Any)])
case .webPageAttributeStickerSet(let flags, let stickers):
@ -94,19 +91,10 @@ public extension Api {
}
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
_4 = reader.readInt32()
var _5: Int32?
_5 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.WebPageAttribute.webPageAttributeStarGiftAuction(gift: _1!, endDate: _2!, centerColor: _3!, edgeColor: _4!, textColor: _5!)
if _c1 && _c2 {
return Api.WebPageAttribute.webPageAttributeStarGiftAuction(gift: _1!, endDate: _2!)
}
else {
return nil

View file

@ -32,11 +32,11 @@ func telegramMediaWebpageAttributeFromApiWebpageAttribute(_ attribute: Api.WebPa
var files: [TelegramMediaFile] = []
files = icons.compactMap { telegramMediaFileFromApiDocument($0, altDocuments: []) }
return .giftCollection(TelegramMediaWebpageGiftCollectionAttribute(files: files))
case let .webPageAttributeStarGiftAuction(apiGift, endDate, centerColor, edgeColor, textColor):
case let .webPageAttributeStarGiftAuction(apiGift, endDate):
guard let gift = StarGift(apiStarGift: apiGift) else {
return nil
}
return .giftAuction(TelegramMediaWebpageGiftAuctionAttribute(gift: gift, endDate: endDate, centerColor: centerColor, edgeColor: edgeColor, textColor: textColor))
return .giftAuction(TelegramMediaWebpageGiftAuctionAttribute(gift: gift, endDate: endDate))
case .webPageAttributeStory:
return nil
}

View file

@ -210,52 +210,28 @@ public final class TelegramMediaWebpageGiftAuctionAttribute: PostboxCoding, Equa
if lhs.endDate != rhs.endDate {
return false
}
if lhs.centerColor != rhs.centerColor {
return false
}
if lhs.edgeColor != rhs.edgeColor {
return false
}
if lhs.textColor != rhs.textColor {
return false
}
return true
}
public let gift: StarGift
public let endDate: Int32
public let centerColor: Int32
public let edgeColor: Int32
public let textColor: Int32
public init(
gift: StarGift,
endDate: Int32,
centerColor: Int32,
edgeColor: Int32,
textColor: Int32
endDate: Int32
) {
self.gift = gift
self.endDate = endDate
self.centerColor = centerColor
self.edgeColor = edgeColor
self.textColor = textColor
}
public init(decoder: PostboxDecoder) {
self.gift = decoder.decodeObjectForKey("gift", decoder: { StarGift(decoder: $0) }) as! StarGift
self.endDate = decoder.decodeInt32ForKey("endDate", orElse: 0)
self.centerColor = decoder.decodeInt32ForKey("centerColor", orElse: 0)
self.edgeColor = decoder.decodeInt32ForKey("edgeColor", orElse: 0)
self.textColor = decoder.decodeInt32ForKey("textColor", orElse: 0)
}
public func encode(_ encoder: PostboxEncoder) {
encoder.encodeObject(self.gift, forKey: "gift")
encoder.encodeInt32(self.endDate, forKey: "endDate")
encoder.encodeInt32(self.centerColor, forKey: "centerColor")
encoder.encodeInt32(self.edgeColor, forKey: "edgeColor")
encoder.encodeInt32(self.textColor, forKey: "textColor")
}
}

View file

@ -64,6 +64,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
case auctionGiftsPerRound
case auctionStartDate
case upgradeVariantsCount
case background
}
public struct Availability: Equatable, Codable, PostboxCoding {
@ -171,6 +172,40 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
}
}
public struct Background: Equatable, Codable, PostboxCoding {
enum CodingKeys: String, CodingKey {
case centerColor
case edgeColor
case textColor
}
public let centerColor: Int32
public let edgeColor: Int32
public let textColor: Int32
public init(
centerColor: Int32,
edgeColor: Int32,
textColor: Int32
) {
self.centerColor = centerColor
self.edgeColor = edgeColor
self.textColor = textColor
}
public init(decoder: PostboxDecoder) {
self.centerColor = decoder.decodeInt32ForKey(CodingKeys.centerColor.rawValue, orElse: 0)
self.edgeColor = decoder.decodeInt32ForKey(CodingKeys.edgeColor.rawValue, orElse: 0)
self.textColor = decoder.decodeInt32ForKey(CodingKeys.textColor.rawValue, orElse: 0)
}
public func encode(_ encoder: PostboxEncoder) {
encoder.encodeInt32(self.centerColor, forKey: CodingKeys.centerColor.rawValue)
encoder.encodeInt32(self.edgeColor, forKey: CodingKeys.edgeColor.rawValue)
encoder.encodeInt32(self.textColor, forKey: CodingKeys.textColor.rawValue)
}
}
public enum DecodingError: Error {
case generic
}
@ -191,8 +226,9 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
public let auctionGiftsPerRound: Int32?
public let auctionStartDate: Int32?
public let upgradeVariantsCount: Int32?
public let background: Background?
public init(id: Int64, title: String?, file: TelegramMediaFile, price: Int64, convertStars: Int64, availability: Availability?, soldOut: SoldOut?, flags: Flags, upgradeStars: Int64?, releasedBy: EnginePeer.Id?, perUserLimit: PerUserLimit?, lockedUntilDate: Int32?, auctionSlug: String?, auctionGiftsPerRound: Int32?, auctionStartDate: Int32?, upgradeVariantsCount: Int32?) {
public init(id: Int64, title: String?, file: TelegramMediaFile, price: Int64, convertStars: Int64, availability: Availability?, soldOut: SoldOut?, flags: Flags, upgradeStars: Int64?, releasedBy: EnginePeer.Id?, perUserLimit: PerUserLimit?, lockedUntilDate: Int32?, auctionSlug: String?, auctionGiftsPerRound: Int32?, auctionStartDate: Int32?, upgradeVariantsCount: Int32?, background: Background?) {
self.id = id
self.title = title
self.file = file
@ -209,6 +245,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
self.auctionGiftsPerRound = auctionGiftsPerRound
self.auctionStartDate = auctionStartDate
self.upgradeVariantsCount = upgradeVariantsCount
self.background = background
}
public init(from decoder: Decoder) throws {
@ -235,6 +272,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
self.auctionGiftsPerRound = try container.decodeIfPresent(Int32.self, forKey: .auctionGiftsPerRound)
self.auctionStartDate = try container.decodeIfPresent(Int32.self, forKey: .auctionStartDate)
self.upgradeVariantsCount = try container.decodeIfPresent(Int32.self, forKey: .upgradeVariantsCount)
self.background = try container.decodeIfPresent(Background.self, forKey: .background)
}
public init(decoder: PostboxDecoder) {
@ -254,6 +292,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
self.auctionGiftsPerRound = decoder.decodeOptionalInt32ForKey(CodingKeys.auctionGiftsPerRound.rawValue)
self.auctionStartDate = decoder.decodeOptionalInt32ForKey(CodingKeys.auctionStartDate.rawValue)
self.upgradeVariantsCount = decoder.decodeOptionalInt32ForKey(CodingKeys.upgradeVariantsCount.rawValue)
self.background = decoder.decodeObjectForKey(CodingKeys.background.rawValue, decoder: { StarGift.Gift.Background(decoder: $0) }) as? StarGift.Gift.Background
}
public func encode(to encoder: Encoder) throws {
@ -279,6 +318,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
try container.encodeIfPresent(self.auctionGiftsPerRound, forKey: .auctionGiftsPerRound)
try container.encodeIfPresent(self.auctionStartDate, forKey: .auctionStartDate)
try container.encodeIfPresent(self.upgradeVariantsCount, forKey: .upgradeVariantsCount)
try container.encodeIfPresent(self.background, forKey: .background)
}
public func encode(_ encoder: PostboxEncoder) {
@ -342,6 +382,11 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
} else {
encoder.encodeNil(forKey: CodingKeys.upgradeVariantsCount.rawValue)
}
if let background = self.background {
encoder.encodeObject(background, forKey: CodingKeys.background.rawValue)
} else {
encoder.encodeNil(forKey: CodingKeys.background.rawValue)
}
}
}
@ -1052,7 +1097,7 @@ public extension StarGift {
extension StarGift {
init?(apiStarGift: Api.StarGift) {
switch apiStarGift {
case let .starGift(apiFlags, id, sticker, stars, availabilityRemains, availabilityTotal, availabilityResale, convertStars, firstSale, lastSale, upgradeStars, minResaleStars, title, releasedBy, perUserTotal, perUserRemains, lockedUntilDate, auctionSlug, giftsPerRound, auctionStartDate, upgradeVariantsCount):
case let .starGift(apiFlags, id, sticker, stars, availabilityRemains, availabilityTotal, availabilityResale, convertStars, firstSale, lastSale, upgradeStars, minResaleStars, title, releasedBy, perUserTotal, perUserRemains, lockedUntilDate, auctionSlug, giftsPerRound, auctionStartDate, upgradeVariantsCount, apiBackground):
var flags = StarGift.Gift.Flags()
if (apiFlags & (1 << 2)) != 0 {
flags.insert(.isBirthdayGift)
@ -1084,6 +1129,13 @@ extension StarGift {
if let perUserTotal, let perUserRemains {
perUserLimit = StarGift.Gift.PerUserLimit(total: perUserTotal, remains: perUserRemains)
}
var background: StarGift.Gift.Background?
switch apiBackground {
case let .starGiftBackground(centerColor, edgeColor, textColor):
background = StarGift.Gift.Background(centerColor: centerColor, edgeColor: edgeColor, textColor: textColor)
default:
break
}
guard let file = telegramMediaFileFromApiDocument(sticker, altDocuments: nil) else {
return nil
}
@ -1103,7 +1155,8 @@ extension StarGift {
auctionSlug: auctionSlug,
auctionGiftsPerRound: giftsPerRound,
auctionStartDate: auctionStartDate,
upgradeVariantsCount: upgradeVariantsCount
upgradeVariantsCount: upgradeVariantsCount,
background: background
))
case let .starGiftUnique(apiFlags, id, giftId, title, slug, num, ownerPeerId, ownerName, ownerAddress, attributes, availabilityIssued, availabilityTotal, giftAddress, resellAmounts, releasedBy, valueAmount, valueCurrency, valueUsdAmount, themePeer, peerColor, hostPeerId, minOfferStars):
let owner: StarGift.UniqueGift.Owner
@ -3077,8 +3130,6 @@ func _internal_getUniqueStarGiftValueInfo(account: Account, slug: String) -> Sig
if let result {
switch result {
case let .uniqueStarGiftValueInfo(flags, currency, value, initialSaleDate, initialSaleStars, initialSalePrice, lastSaleDate, lastSalePrice, floorPrice, averagePrice, listedCount, fragmentListedCount, fragmentListedUrl):
let _ = listedCount
let _ = fragmentListedCount
return StarGift.UniqueGift.ValueInfo(
isLastSaleOnFragment: flags & (1 << 1) != 0,
valueIsAverage: flags & (1 << 6) != 0,

View file

@ -75,7 +75,7 @@ public final class GiftAuctionContext {
public enum AuctionState: Equatable {
case ongoing(version: Int32, startDate: Int32, endDate: Int32, minBidAmount: Int64, bidLevels: [BidLevel], topBidders: [EnginePeer], nextRoundDate: Int32, giftsLeft: Int32, currentRound: Int32, totalRounds: Int32, rounds: [Round], lastGiftNumber: Int32)
case finished(startDate: Int32, endDate: Int32, averagePrice: Int64)
case finished(startDate: Int32, endDate: Int32, averagePrice: Int64, listedCount: Int32?, fragmentListedCount: Int32?, fragmentListedUrl: String?)
}
public struct MyState: Equatable {
@ -260,9 +260,29 @@ extension GiftAuctionContext.State.AuctionState {
rounds.append(.extendable(num: num, duration: duration, extendTop: extendTop, extendWindow: extendWindow))
}
}
self = .ongoing(version: version, startDate: startDate, endDate: endDate, minBidAmount: minBidAmount, bidLevels: bidLevels.map(GiftAuctionContext.State.BidLevel.init(apiBidLevel:)), topBidders: topBidders, nextRoundDate: nextRoundAt, giftsLeft: giftsLeft, currentRound: currentRound, totalRounds: totalRounds, rounds: rounds, lastGiftNumber: lastGiftNumber)
case let .starGiftAuctionStateFinished(startDate, endDate, averagePrice):
self = .finished(startDate: startDate, endDate: endDate, averagePrice: averagePrice)
self = .ongoing(
version: version,
startDate: startDate,
endDate: endDate,
minBidAmount: minBidAmount,
bidLevels: bidLevels.map(GiftAuctionContext.State.BidLevel.init(apiBidLevel:)),
topBidders: topBidders,
nextRoundDate: nextRoundAt,
giftsLeft: giftsLeft,
currentRound: currentRound,
totalRounds: totalRounds,
rounds: rounds,
lastGiftNumber: lastGiftNumber
)
case let .starGiftAuctionStateFinished(_, startDate, endDate, averagePrice, listedCount, fragmentListedCount, fragmentListedUrl):
self = .finished(
startDate: startDate,
endDate: endDate,
averagePrice: averagePrice,
listedCount: listedCount,
fragmentListedCount: fragmentListedCount,
fragmentListedUrl: fragmentListedUrl
)
case .starGiftAuctionStateNotModified:
return nil
}
@ -286,9 +306,29 @@ extension GiftAuctionContext.State.AuctionState {
rounds.append(.extendable(num: num, duration: duration, extendTop: extendTop, extendWindow: extendWindow))
}
}
self = .ongoing(version: version, startDate: startDate, endDate: endDate, minBidAmount: minBidAmount, bidLevels: bidLevels.map(GiftAuctionContext.State.BidLevel.init(apiBidLevel:)), topBidders: topBidders, nextRoundDate: nextRoundAt, giftsLeft: giftsLeft, currentRound: currentRound, totalRounds: totalRounds, rounds: rounds, lastGiftNumber: lastGiftNumber)
case let .starGiftAuctionStateFinished(startDate, endDate, averagePrice):
self = .finished(startDate: startDate, endDate: endDate, averagePrice: averagePrice)
self = .ongoing(
version: version,
startDate: startDate,
endDate: endDate,
minBidAmount: minBidAmount,
bidLevels: bidLevels.map(GiftAuctionContext.State.BidLevel.init(apiBidLevel:)),
topBidders: topBidders,
nextRoundDate: nextRoundAt,
giftsLeft: giftsLeft,
currentRound: currentRound,
totalRounds: totalRounds,
rounds: rounds,
lastGiftNumber: lastGiftNumber
)
case let .starGiftAuctionStateFinished(_, startDate, endDate, averagePrice, listedCount, fragmentListedCount, fragmentListedUrl):
self = .finished(
startDate: startDate,
endDate: endDate,
averagePrice: averagePrice,
listedCount: listedCount,
fragmentListedCount: fragmentListedCount,
fragmentListedUrl: fragmentListedUrl
)
case .starGiftAuctionStateNotModified:
return nil
}
@ -591,7 +631,7 @@ public extension GiftAuctionContext.State {
switch self.auctionState {
case let .ongoing(_, startDate, _, _, _, _, _, _, _, _, _, _):
return startDate
case let .finished(startDate, _, _):
case let .finished(startDate, _, _, _, _, _):
return startDate
}
}
@ -600,7 +640,7 @@ public extension GiftAuctionContext.State {
switch self.auctionState {
case let .ongoing(_, _, endDate, _, _, _, _, _, _, _, _, _):
return endDate
case let .finished(_, endDate, _):
case let .finished(_, endDate, _, _, _, _):
return endDate
}
}

View file

@ -2223,7 +2223,7 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
giftView = ComponentView()
strongSelf.giftView = giftView
}
let _ = giftView.update(
transition: .immediate,
component: AnyComponent(
@ -2231,7 +2231,7 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
context: context,
theme: presentationData.theme.theme,
strings: presentationData.strings,
subject: .auction(gift: gift, centerColor: giftPreview.centerColor, edgeColor: giftPreview.edgeColor, endTime: giftPreview.endTime),
subject: .auction(gift: gift, endTime: giftPreview.endTime),
title: gift.title ?? "",
subtitle: presentationData.strings.Chat_Auction_Gifts(gift.availability?.total ?? 0),
mode: .preview

View file

@ -346,7 +346,7 @@ public final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContent
case "telegram_auction":
for attribute in webpage.attributes {
if case let .giftAuction(giftAuction) = attribute, case let .generic(gift) = giftAuction.gift {
let media = GiftAuctionPreviewMedia(content: gift, centerColor: UIColor(rgb: UInt32(bitPattern: giftAuction.centerColor)), edgeColor: UIColor(rgb: UInt32(bitPattern: giftAuction.edgeColor)), endTime: giftAuction.endDate)
let media = GiftAuctionPreviewMedia(content: gift, endTime: giftAuction.endDate)
mediaAndFlags = ([media], [])
break
}

View file

@ -29,7 +29,7 @@ public final class GiftItemComponent: Component {
case premium(months: Int32, price: String)
case starGift(gift: StarGift.Gift, price: String)
case uniqueGift(gift: StarGift.UniqueGift, price: String?)
case auction(gift: StarGift.Gift, centerColor: UIColor, edgeColor: UIColor, endTime: Int32)
case auction(gift: StarGift.Gift, endTime: Int32)
case preview(attributes: [StarGift.UniqueGift.Attribute], rarity: Int32)
}
@ -533,13 +533,19 @@ public final class GiftItemComponent: Component {
} else {
emoji = nil
}
case let .auction(gift, centerColor, edgeColor, endTime):
case let .auction(gift, endTime):
animationOffset = 16.0
explicitAnimationOffset = -16.0
animationFile = gift.file
backgroundColor = edgeColor
secondBackgroundColor = centerColor
if let background = gift.background {
backgroundColor = UIColor(rgb: UInt32(bitPattern: background.edgeColor))
secondBackgroundColor = UIColor(rgb: UInt32(bitPattern: background.centerColor))
} else {
backgroundColor = UIColor.black
secondBackgroundColor = UIColor.black
}
emoji = ChatTextInputTextCustomEmojiAttribute(
interactivelySelectedFromPackId: nil,
fileId: gift.file.fileId.id,

View file

@ -518,7 +518,7 @@ private final class GiftAuctionViewSheetContent: CombinedComponent {
MultilineTextComponent(text: .plain(NSAttributedString(string: stringForMediumDate(timestamp: auctionState.endDate, strings: strings, dateTimeFormat: dateTimeFormat), font: tableFont, textColor: tableTextColor)))
)
))
if case let .finished(_, _, averagePrice) = auctionState.auctionState {
if case let .finished(_, _, averagePrice, _, _, _) = auctionState.auctionState {
var items: [AnyComponentWithIdentity<Empty>] = []
let valueString = "\(presentationStringsFormattedNumber(abs(Int32(clamping: averagePrice)), dateTimeFormat.groupingSeparator))⭐️"

View file

@ -28,11 +28,17 @@ private final class GiftUpgradePreviewScreenComponent: Component {
typealias EnvironmentType = ViewControllerComponentContainer.Environment
let context: AccountContext
let gift: StarGift
let attributes: [StarGift.UniqueGift.Attribute]
init(
context: AccountContext
context: AccountContext,
gift: StarGift,
attributes: [StarGift.UniqueGift.Attribute]
) {
self.context = context
self.gift = gift
self.attributes = attributes
}
static func ==(lhs: GiftUpgradePreviewScreenComponent, rhs: GiftUpgradePreviewScreenComponent) -> Bool {
@ -96,11 +102,7 @@ private final class GiftUpgradePreviewScreenComponent: Component {
private var selectedSection: SelectedSection = .models
private let giftCompositionExternalState = GiftCompositionComponent.ExternalState()
fileprivate var starGiftsContext: ResaleGiftsContext?
fileprivate var starGiftsState: ResaleGiftsContext.State?
fileprivate var starGiftsDisposable: Disposable?
private var previewTimer: SwiftSignalKit.Timer?
private var isPlaying = true
private var showRandomizeTip = false
@ -191,10 +193,6 @@ private final class GiftUpgradePreviewScreenComponent: Component {
fatalError("init(coder:) has not been implemented")
}
deinit {
self.starGiftsDisposable?.dispose()
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if !self.ignoreScrolling {
self.updateScrolling(transition: .immediate)
@ -312,14 +310,14 @@ private final class GiftUpgradePreviewScreenComponent: Component {
private var effectiveGifts: [[StarGift.UniqueGift.Attribute]] = []
private func updateEffectiveGifts() {
guard let starGiftsState = self.starGiftsState else {
guard let component = self.component else {
return
}
var effectiveGifts: [[StarGift.UniqueGift.Attribute]] = []
switch self.selectedSection {
case .models:
let models = Array(starGiftsState.attributes.filter({ attribute in
let models = Array(component.attributes.filter({ attribute in
if case .model = attribute {
return true
} else {
@ -332,7 +330,7 @@ private final class GiftUpgradePreviewScreenComponent: Component {
case .backdrops:
let selectedModel = self.selectedModel ?? self.previewModels[self.previewModelIndex]
let selectedSymbol = self.selectedSymbol ?? self.previewSymbols[self.previewSymbolIndex]
let backdrops = Array(starGiftsState.attributes.filter({ attribute in
let backdrops = Array(component.attributes.filter({ attribute in
if case .backdrop = attribute {
return true
} else {
@ -348,7 +346,7 @@ private final class GiftUpgradePreviewScreenComponent: Component {
}
case .symbols:
let selectedBackdrop = self.selectedBackdrop ?? self.previewBackdrops[self.previewBackdropIndex]
let symbols = Array(starGiftsState.attributes.filter({ attribute in
let symbols = Array(component.attributes.filter({ attribute in
if case .pattern = attribute {
return true
} else {
@ -570,73 +568,54 @@ private final class GiftUpgradePreviewScreenComponent: Component {
let sideInset: CGFloat = rawSideInset + 16.0
if self.component == nil {
let giftIds: [Int64] = [
6014675319464657779,
6042113507581755979,
5936013938331222567
]
self.starGiftsContext = ResaleGiftsContext(account: component.context.account, giftId: giftIds.randomElement()!)
self.starGiftsDisposable = (self.starGiftsContext!.state
|> deliverOnMainQueue).start(next: { [weak self] state in
guard let self else {
return
var modelCount: Int32 = 0
var backdropCount: Int32 = 0
var symbolCount: Int32 = 0
for attribute in component.attributes {
switch attribute {
case .model:
modelCount += 1
case .backdrop:
backdropCount += 1
case .pattern:
symbolCount += 1
default:
break
}
let isFirstTime = self.starGiftsState?.attributes.isEmpty ?? true
self.starGiftsState = state
var modelCount: Int32 = 0
var backdropCount: Int32 = 0
var symbolCount: Int32 = 0
for attribute in state.attributes {
switch attribute {
case .model:
modelCount += 1
case .backdrop:
backdropCount += 1
case .pattern:
symbolCount += 1
default:
break
}
}
self.modelCount = modelCount
self.backdropCount = backdropCount
self.symbolCount = symbolCount
let randomModels = Array(component.attributes.filter({ attribute in
if case .model = attribute {
return true
} else {
return false
}
self.modelCount = modelCount
self.backdropCount = backdropCount
self.symbolCount = symbolCount
if isFirstTime {
let randomModels = Array(state.attributes.filter({ attribute in
if case .model = attribute {
return true
} else {
return false
}
}).shuffled().prefix(15))
self.previewModels = randomModels
let randomBackdrops = Array(state.attributes.filter({ attribute in
if case .backdrop = attribute {
return true
} else {
return false
}
}).shuffled())
self.previewBackdrops = randomBackdrops
let randomSymbols = Array(state.attributes.filter({ attribute in
if case .pattern = attribute {
return true
} else {
return false
}
}).shuffled().prefix(15))
self.previewSymbols = randomSymbols
self.updateEffectiveGifts()
}).shuffled().prefix(15))
self.previewModels = randomModels
let randomBackdrops = Array(component.attributes.filter({ attribute in
if case .backdrop = attribute {
return true
} else {
return false
}
self.state?.updated(transition: .immediate)
})
}).shuffled())
self.previewBackdrops = randomBackdrops
let randomSymbols = Array(component.attributes.filter({ attribute in
if case .pattern = attribute {
return true
} else {
return false
}
}).shuffled().prefix(15))
self.previewSymbols = randomSymbols
self.updateEffectiveGifts()
}
self.component = component
@ -731,8 +710,8 @@ private final class GiftUpgradePreviewScreenComponent: Component {
contentHeight += headerSize.height
var titleText: String = ""
if let gift = self.starGiftsState?.gifts.first, case let .unique(gift) = gift {
titleText = gift.title
if case let .generic(gift) = component.gift {
titleText = gift.title ?? ""
}
let titleSize = self.title.update(
@ -1156,11 +1135,17 @@ public class GiftUpgradePreviewScreen: ViewControllerComponentContainer {
private var didPlayAppearAnimation: Bool = false
private var isDismissed: Bool = false
public init(context: AccountContext) {
public init(
context: AccountContext,
gift: StarGift,
attributes: [StarGift.UniqueGift.Attribute]
) {
self.context = context
super.init(context: context, component: GiftUpgradePreviewScreenComponent(
context: context
context: context,
gift: gift,
attributes: attributes
), navigationBarAppearance: .none, theme: .default)
self.statusBar.statusBarStyle = .Ignore

View file

@ -117,21 +117,15 @@ public final class GiftAuctionPreviewMedia: Media {
public let peerIds: [PeerId] = []
public let content: StarGift.Gift?
public let centerColor: UIColor
public let edgeColor: UIColor
public let endTime: Int32
public init(content: StarGift.Gift, centerColor: UIColor, edgeColor: UIColor, endTime: Int32) {
public init(content: StarGift.Gift, endTime: Int32) {
self.content = content
self.centerColor = centerColor
self.edgeColor = edgeColor
self.endTime = endTime
}
public init(decoder: PostboxDecoder) {
self.content = nil
self.centerColor = .clear
self.edgeColor = .clear
self.endTime = 0
}

View file

@ -3867,6 +3867,10 @@ public final class SharedAccountContextImpl: SharedAccountContext {
return giftOfferAlertController(context: context, gift: gift, peer: peer, amount: amount, commit: commit)
}
public func makeGiftUpgradeVariantsPreviewScreen(context: AccountContext, gift: StarGift, attributes: [StarGift.UniqueGift.Attribute]) -> ViewController {
return GiftUpgradePreviewScreen(context: context, gift: gift, attributes: attributes)
}
public func makeStorySharingScreen(context: AccountContext, subject: StorySharingSubject, parentController: ViewController) -> ViewController {
let editorSubject: Signal<MediaEditorScreenImpl.Subject?, NoError>
switch subject {