This commit is contained in:
Isaac 2025-10-24 13:34:55 +04:00
parent eebfe1acae
commit 1967e1e273
15 changed files with 720 additions and 227 deletions

6
MODULE.bazel.lock generated
View file

@ -11,7 +11,6 @@
"https://bcr.bazel.build/modules/abseil-cpp/20240116.1/MODULE.bazel": "37bcdb4440fbb61df6a1c296ae01b327f19e9bb521f9b8e26ec854b6f97309ed",
"https://bcr.bazel.build/modules/abseil-cpp/20240116.1/source.json": "9be551b8d4e3ef76875c0d744b5d6a504a27e3ae67bc6b28f46415fd2d2957da",
"https://bcr.bazel.build/modules/bazel_features/1.1.1/MODULE.bazel": "27b8c79ef57efe08efccbd9dd6ef70d61b4798320b8d3c134fd571f78963dbcd",
"https://bcr.bazel.build/modules/bazel_features/1.10.0/MODULE.bazel": "f75e8807570484a99be90abcd52b5e1f390362c258bcb73106f4544957a48101",
"https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8",
"https://bcr.bazel.build/modules/bazel_features/1.15.0/MODULE.bazel": "d38ff6e517149dc509406aca0db3ad1efdd890a85e049585b7234d04238e2a4d",
"https://bcr.bazel.build/modules/bazel_features/1.17.0/MODULE.bazel": "039de32d21b816b47bd42c778e0454217e9c9caac4a3cf8e15c7231ee3ddee4d",
@ -24,6 +23,7 @@
"https://bcr.bazel.build/modules/bazel_features/1.30.0/MODULE.bazel": "a14b62d05969a293b80257e72e597c2da7f717e1e69fa8b339703ed6731bec87",
"https://bcr.bazel.build/modules/bazel_features/1.30.0/source.json": "b07e17f067fe4f69f90b03b36ef1e08fe0d1f3cac254c1241a1818773e3423bc",
"https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7",
"https://bcr.bazel.build/modules/bazel_features/1.9.0/MODULE.bazel": "885151d58d90d8d9c811eb75e3288c11f850e1d6b481a8c9f766adee4712358b",
"https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a",
"https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8",
"https://bcr.bazel.build/modules/bazel_skylib/1.1.1/MODULE.bazel": "1add3e7d93ff2e6998f9e118022c84d163917d912f5afafb3058e3d2f1545b5e",
@ -144,8 +144,8 @@
"https://bcr.bazel.build/modules/stardoc/0.7.1/MODULE.bazel": "3548faea4ee5dda5580f9af150e79d0f6aea934fc60c1cc50f4efdd9420759e7",
"https://bcr.bazel.build/modules/stardoc/0.7.2/MODULE.bazel": "fc152419aa2ea0f51c29583fab1e8c99ddefd5b3778421845606ee628629e0e5",
"https://bcr.bazel.build/modules/stardoc/0.7.2/source.json": "58b029e5e901d6802967754adf0a9056747e8176f017cfe3607c0851f4d42216",
"https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.2/MODULE.bazel": "75aab2373a4bbe2a1260b9bf2a1ebbdbf872d3bd36f80bff058dccd82e89422f",
"https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.2/source.json": "5fba48bbe0ba48761f9e9f75f92876cafb5d07c0ce059cc7a8027416de94a05b",
"https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/MODULE.bazel": "5e463fbfba7b1701d957555ed45097d7f984211330106ccd1352c6e0af0dcf91",
"https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/source.json": "32bd87e5f4d7acc57c5b2ff7c325ae3061d5e242c0c4c214ae87e0f1c13e54cb",
"https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43",
"https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0",
"https://bcr.bazel.build/modules/zlib/1.3.1.bcr.5/MODULE.bazel": "eec517b5bbe5492629466e11dae908d043364302283de25581e3eb944326c4ca",

View file

@ -303,6 +303,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-29248689] = { return Api.GlobalPrivacySettings.parse_globalPrivacySettings($0) }
dict[-674602536] = { return Api.GroupCall.parse_groupCall($0) }
dict[2004925620] = { return Api.GroupCall.parse_groupCallDiscarded($0) }
dict[-297595771] = { return Api.GroupCallDonor.parse_groupCallDonor($0) }
dict[445316222] = { return Api.GroupCallMessage.parse_groupCallMessage($0) }
dict[708691884] = { return Api.GroupCallParticipant.parse_groupCallParticipant($0) }
dict[1735736008] = { return Api.GroupCallParticipantVideo.parse_groupCallParticipantVideo($0) }
@ -1485,6 +1486,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-784000893] = { return Api.payments.ValidatedRequestedInfo.parse_validatedRequestedInfo($0) }
dict[541839704] = { return Api.phone.ExportedGroupCallInvite.parse_exportedGroupCallInvite($0) }
dict[-1636664659] = { return Api.phone.GroupCall.parse_groupCall($0) }
dict[-1658995418] = { return Api.phone.GroupCallStars.parse_groupCallStars($0) }
dict[-790330702] = { return Api.phone.GroupCallStreamChannels.parse_groupCallStreamChannels($0) }
dict[767505458] = { return Api.phone.GroupCallStreamRtmpUrl.parse_groupCallStreamRtmpUrl($0) }
dict[-193506890] = { return Api.phone.GroupParticipants.parse_groupParticipants($0) }
@ -1820,6 +1822,8 @@ public extension Api {
_1.serialize(buffer, boxed)
case let _1 as Api.GroupCall:
_1.serialize(buffer, boxed)
case let _1 as Api.GroupCallDonor:
_1.serialize(buffer, boxed)
case let _1 as Api.GroupCallMessage:
_1.serialize(buffer, boxed)
case let _1 as Api.GroupCallParticipant:
@ -2640,6 +2644,8 @@ public extension Api {
_1.serialize(buffer, boxed)
case let _1 as Api.phone.GroupCall:
_1.serialize(buffer, boxed)
case let _1 as Api.phone.GroupCallStars:
_1.serialize(buffer, boxed)
case let _1 as Api.phone.GroupCallStreamChannels:
_1.serialize(buffer, boxed)
case let _1 as Api.phone.GroupCallStreamRtmpUrl:

View file

@ -1094,6 +1094,72 @@ public extension Api.phone {
}
}
public extension Api.phone {
enum GroupCallStars: TypeConstructorDescription {
case groupCallStars(totalStars: Int64, topDonors: [Api.GroupCallDonor], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .groupCallStars(let totalStars, let topDonors, let chats, let users):
if boxed {
buffer.appendInt32(-1658995418)
}
serializeInt64(totalStars, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(topDonors.count))
for item in topDonors {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .groupCallStars(let totalStars, let topDonors, let chats, let users):
return ("groupCallStars", [("totalStars", totalStars as Any), ("topDonors", topDonors as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_groupCallStars(_ reader: BufferReader) -> GroupCallStars? {
var _1: Int64?
_1 = reader.readInt64()
var _2: [Api.GroupCallDonor]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.GroupCallDonor.self)
}
var _3: [Api.Chat]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _4: [Api.User]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.phone.GroupCallStars.groupCallStars(totalStars: _1!, topDonors: _2!, chats: _3!, users: _4!)
}
else {
return nil
}
}
}
}
public extension Api.phone {
enum GroupCallStreamChannels: TypeConstructorDescription {
case groupCallStreamChannels(channels: [Api.GroupCallStreamChannel])
@ -1650,65 +1716,3 @@ public extension Api.premium {
}
}
public extension Api.premium {
enum MyBoosts: TypeConstructorDescription {
case myBoosts(myBoosts: [Api.MyBoost], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .myBoosts(let myBoosts, let chats, let users):
if boxed {
buffer.appendInt32(-1696454430)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(myBoosts.count))
for item in myBoosts {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .myBoosts(let myBoosts, let chats, let users):
return ("myBoosts", [("myBoosts", myBoosts as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_myBoosts(_ reader: BufferReader) -> MyBoosts? {
var _1: [Api.MyBoost]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MyBoost.self)
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.premium.MyBoosts.myBoosts(myBoosts: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}

View file

@ -1,3 +1,65 @@
public extension Api.premium {
enum MyBoosts: TypeConstructorDescription {
case myBoosts(myBoosts: [Api.MyBoost], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .myBoosts(let myBoosts, let chats, let users):
if boxed {
buffer.appendInt32(-1696454430)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(myBoosts.count))
for item in myBoosts {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .myBoosts(let myBoosts, let chats, let users):
return ("myBoosts", [("myBoosts", myBoosts as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_myBoosts(_ reader: BufferReader) -> MyBoosts? {
var _1: [Api.MyBoost]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MyBoost.self)
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.premium.MyBoosts.myBoosts(myBoosts: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}
public extension Api.smsjobs {
enum EligibilityToJoin: TypeConstructorDescription {
case eligibleToJoin(termsUrl: String, monthlySentSms: Int32)

View file

@ -10593,6 +10593,21 @@ public extension Api.functions.phone {
})
}
}
public extension Api.functions.phone {
static func getGroupCallStars(call: Api.InputGroupCall) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.phone.GroupCallStars>) {
let buffer = Buffer()
buffer.appendInt32(1868784386)
call.serialize(buffer, true)
return (FunctionDescription(name: "phone.getGroupCallStars", parameters: [("call", String(describing: call))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.phone.GroupCallStars? in
let reader = BufferReader(buffer)
var result: Api.phone.GroupCallStars?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.phone.GroupCallStars
}
return result
})
}
}
public extension Api.functions.phone {
static func getGroupCallStreamChannels(call: Api.InputGroupCall) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.phone.GroupCallStreamChannels>) {
let buffer = Buffer()

View file

@ -1332,6 +1332,52 @@ public extension Api {
}
}
public extension Api {
enum GroupCallDonor: TypeConstructorDescription {
case groupCallDonor(flags: Int32, peerId: Api.Peer?, stars: Int64)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .groupCallDonor(let flags, let peerId, let stars):
if boxed {
buffer.appendInt32(-297595771)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 3) != 0 {peerId!.serialize(buffer, true)}
serializeInt64(stars, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .groupCallDonor(let flags, let peerId, let stars):
return ("groupCallDonor", [("flags", flags as Any), ("peerId", peerId as Any), ("stars", stars as Any)])
}
}
public static func parse_groupCallDonor(_ reader: BufferReader) -> GroupCallDonor? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.Peer?
if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.Peer
} }
var _3: Int64?
_3 = reader.readInt64()
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 3) == 0) || _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.GroupCallDonor.groupCallDonor(flags: _1!, peerId: _2, stars: _3!)
}
else {
return nil
}
}
}
}
public extension Api {
enum GroupCallMessage: TypeConstructorDescription {
case groupCallMessage(flags: Int32, id: Int32, fromId: Api.Peer, date: Int32, message: Api.TextWithEntities, paidMessageStars: Int64?)
@ -1392,85 +1438,3 @@ public extension Api {
}
}
public extension Api {
enum GroupCallParticipant: TypeConstructorDescription {
case groupCallParticipant(flags: Int32, peer: Api.Peer, date: Int32, activeDate: Int32?, source: Int32, volume: Int32?, about: String?, raiseHandRating: Int64?, video: Api.GroupCallParticipantVideo?, presentation: Api.GroupCallParticipantVideo?, paidStarsTotal: Int64?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .groupCallParticipant(let flags, let peer, let date, let activeDate, let source, let volume, let about, let raiseHandRating, let video, let presentation, let paidStarsTotal):
if boxed {
buffer.appendInt32(708691884)
}
serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
serializeInt32(date, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(activeDate!, buffer: buffer, boxed: false)}
serializeInt32(source, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 7) != 0 {serializeInt32(volume!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 11) != 0 {serializeString(about!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 13) != 0 {serializeInt64(raiseHandRating!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 6) != 0 {video!.serialize(buffer, true)}
if Int(flags) & Int(1 << 14) != 0 {presentation!.serialize(buffer, true)}
if Int(flags) & Int(1 << 16) != 0 {serializeInt64(paidStarsTotal!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .groupCallParticipant(let flags, let peer, let date, let activeDate, let source, let volume, let about, let raiseHandRating, let video, let presentation, let paidStarsTotal):
return ("groupCallParticipant", [("flags", flags as Any), ("peer", peer as Any), ("date", date as Any), ("activeDate", activeDate as Any), ("source", source as Any), ("volume", volume as Any), ("about", about as Any), ("raiseHandRating", raiseHandRating as Any), ("video", video as Any), ("presentation", presentation as Any), ("paidStarsTotal", paidStarsTotal as Any)])
}
}
public static func parse_groupCallParticipant(_ reader: BufferReader) -> GroupCallParticipant? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.Peer?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.Peer
}
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
if Int(_1!) & Int(1 << 3) != 0 {_4 = reader.readInt32() }
var _5: Int32?
_5 = reader.readInt32()
var _6: Int32?
if Int(_1!) & Int(1 << 7) != 0 {_6 = reader.readInt32() }
var _7: String?
if Int(_1!) & Int(1 << 11) != 0 {_7 = parseString(reader) }
var _8: Int64?
if Int(_1!) & Int(1 << 13) != 0 {_8 = reader.readInt64() }
var _9: Api.GroupCallParticipantVideo?
if Int(_1!) & Int(1 << 6) != 0 {if let signature = reader.readInt32() {
_9 = Api.parse(reader, signature: signature) as? Api.GroupCallParticipantVideo
} }
var _10: Api.GroupCallParticipantVideo?
if Int(_1!) & Int(1 << 14) != 0 {if let signature = reader.readInt32() {
_10 = Api.parse(reader, signature: signature) as? Api.GroupCallParticipantVideo
} }
var _11: Int64?
if Int(_1!) & Int(1 << 16) != 0 {_11 = reader.readInt64() }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 3) == 0) || _4 != nil
let _c5 = _5 != nil
let _c6 = (Int(_1!) & Int(1 << 7) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 11) == 0) || _7 != nil
let _c8 = (Int(_1!) & Int(1 << 13) == 0) || _8 != nil
let _c9 = (Int(_1!) & Int(1 << 6) == 0) || _9 != nil
let _c10 = (Int(_1!) & Int(1 << 14) == 0) || _10 != nil
let _c11 = (Int(_1!) & Int(1 << 16) == 0) || _11 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 {
return Api.GroupCallParticipant.groupCallParticipant(flags: _1!, peer: _2!, date: _3!, activeDate: _4, source: _5!, volume: _6, about: _7, raiseHandRating: _8, video: _9, presentation: _10, paidStarsTotal: _11)
}
else {
return nil
}
}
}
}

View file

@ -1,3 +1,85 @@
public extension Api {
enum GroupCallParticipant: TypeConstructorDescription {
case groupCallParticipant(flags: Int32, peer: Api.Peer, date: Int32, activeDate: Int32?, source: Int32, volume: Int32?, about: String?, raiseHandRating: Int64?, video: Api.GroupCallParticipantVideo?, presentation: Api.GroupCallParticipantVideo?, paidStarsTotal: Int64?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .groupCallParticipant(let flags, let peer, let date, let activeDate, let source, let volume, let about, let raiseHandRating, let video, let presentation, let paidStarsTotal):
if boxed {
buffer.appendInt32(708691884)
}
serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
serializeInt32(date, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(activeDate!, buffer: buffer, boxed: false)}
serializeInt32(source, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 7) != 0 {serializeInt32(volume!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 11) != 0 {serializeString(about!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 13) != 0 {serializeInt64(raiseHandRating!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 6) != 0 {video!.serialize(buffer, true)}
if Int(flags) & Int(1 << 14) != 0 {presentation!.serialize(buffer, true)}
if Int(flags) & Int(1 << 16) != 0 {serializeInt64(paidStarsTotal!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .groupCallParticipant(let flags, let peer, let date, let activeDate, let source, let volume, let about, let raiseHandRating, let video, let presentation, let paidStarsTotal):
return ("groupCallParticipant", [("flags", flags as Any), ("peer", peer as Any), ("date", date as Any), ("activeDate", activeDate as Any), ("source", source as Any), ("volume", volume as Any), ("about", about as Any), ("raiseHandRating", raiseHandRating as Any), ("video", video as Any), ("presentation", presentation as Any), ("paidStarsTotal", paidStarsTotal as Any)])
}
}
public static func parse_groupCallParticipant(_ reader: BufferReader) -> GroupCallParticipant? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.Peer?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.Peer
}
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
if Int(_1!) & Int(1 << 3) != 0 {_4 = reader.readInt32() }
var _5: Int32?
_5 = reader.readInt32()
var _6: Int32?
if Int(_1!) & Int(1 << 7) != 0 {_6 = reader.readInt32() }
var _7: String?
if Int(_1!) & Int(1 << 11) != 0 {_7 = parseString(reader) }
var _8: Int64?
if Int(_1!) & Int(1 << 13) != 0 {_8 = reader.readInt64() }
var _9: Api.GroupCallParticipantVideo?
if Int(_1!) & Int(1 << 6) != 0 {if let signature = reader.readInt32() {
_9 = Api.parse(reader, signature: signature) as? Api.GroupCallParticipantVideo
} }
var _10: Api.GroupCallParticipantVideo?
if Int(_1!) & Int(1 << 14) != 0 {if let signature = reader.readInt32() {
_10 = Api.parse(reader, signature: signature) as? Api.GroupCallParticipantVideo
} }
var _11: Int64?
if Int(_1!) & Int(1 << 16) != 0 {_11 = reader.readInt64() }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 3) == 0) || _4 != nil
let _c5 = _5 != nil
let _c6 = (Int(_1!) & Int(1 << 7) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 11) == 0) || _7 != nil
let _c8 = (Int(_1!) & Int(1 << 13) == 0) || _8 != nil
let _c9 = (Int(_1!) & Int(1 << 6) == 0) || _9 != nil
let _c10 = (Int(_1!) & Int(1 << 14) == 0) || _10 != nil
let _c11 = (Int(_1!) & Int(1 << 16) == 0) || _11 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 {
return Api.GroupCallParticipant.groupCallParticipant(flags: _1!, peer: _2!, date: _3!, activeDate: _4, source: _5!, volume: _6, about: _7, raiseHandRating: _8, video: _9, presentation: _10, paidStarsTotal: _11)
}
else {
return nil
}
}
}
}
public extension Api {
enum GroupCallParticipantVideo: TypeConstructorDescription {
case groupCallParticipantVideo(flags: Int32, endpoint: String, sourceGroups: [Api.GroupCallParticipantVideoSourceGroup], audioSource: Int32?)
@ -1190,59 +1272,3 @@ public extension Api {
}
}
public extension Api {
enum InputBusinessBotRecipients: TypeConstructorDescription {
case inputBusinessBotRecipients(flags: Int32, users: [Api.InputUser]?, excludeUsers: [Api.InputUser]?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .inputBusinessBotRecipients(let flags, let users, let excludeUsers):
if boxed {
buffer.appendInt32(-991587810)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 4) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users!.count))
for item in users! {
item.serialize(buffer, true)
}}
if Int(flags) & Int(1 << 6) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(excludeUsers!.count))
for item in excludeUsers! {
item.serialize(buffer, true)
}}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .inputBusinessBotRecipients(let flags, let users, let excludeUsers):
return ("inputBusinessBotRecipients", [("flags", flags as Any), ("users", users as Any), ("excludeUsers", excludeUsers as Any)])
}
}
public static func parse_inputBusinessBotRecipients(_ reader: BufferReader) -> InputBusinessBotRecipients? {
var _1: Int32?
_1 = reader.readInt32()
var _2: [Api.InputUser]?
if Int(_1!) & Int(1 << 4) != 0 {if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputUser.self)
} }
var _3: [Api.InputUser]?
if Int(_1!) & Int(1 << 6) != 0 {if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputUser.self)
} }
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 4) == 0) || _2 != nil
let _c3 = (Int(_1!) & Int(1 << 6) == 0) || _3 != nil
if _c1 && _c2 && _c3 {
return Api.InputBusinessBotRecipients.inputBusinessBotRecipients(flags: _1!, users: _2, excludeUsers: _3)
}
else {
return nil
}
}
}
}

View file

@ -1,3 +1,59 @@
public extension Api {
enum InputBusinessBotRecipients: TypeConstructorDescription {
case inputBusinessBotRecipients(flags: Int32, users: [Api.InputUser]?, excludeUsers: [Api.InputUser]?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .inputBusinessBotRecipients(let flags, let users, let excludeUsers):
if boxed {
buffer.appendInt32(-991587810)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 4) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users!.count))
for item in users! {
item.serialize(buffer, true)
}}
if Int(flags) & Int(1 << 6) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(excludeUsers!.count))
for item in excludeUsers! {
item.serialize(buffer, true)
}}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .inputBusinessBotRecipients(let flags, let users, let excludeUsers):
return ("inputBusinessBotRecipients", [("flags", flags as Any), ("users", users as Any), ("excludeUsers", excludeUsers as Any)])
}
}
public static func parse_inputBusinessBotRecipients(_ reader: BufferReader) -> InputBusinessBotRecipients? {
var _1: Int32?
_1 = reader.readInt32()
var _2: [Api.InputUser]?
if Int(_1!) & Int(1 << 4) != 0 {if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputUser.self)
} }
var _3: [Api.InputUser]?
if Int(_1!) & Int(1 << 6) != 0 {if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputUser.self)
} }
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 4) == 0) || _2 != nil
let _c3 = (Int(_1!) & Int(1 << 6) == 0) || _3 != nil
if _c1 && _c2 && _c3 {
return Api.InputBusinessBotRecipients.inputBusinessBotRecipients(flags: _1!, users: _2, excludeUsers: _3)
}
else {
return nil
}
}
}
}
public extension Api {
enum InputBusinessChatLink: TypeConstructorDescription {
case inputBusinessChatLink(flags: Int32, message: String, entities: [Api.MessageEntity]?, title: String?)

View file

@ -832,7 +832,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
}
}
}
private let messagesStatePromise = Promise<GroupCallMessagesContext.State>(GroupCallMessagesContext.State(messages: [], pinnedMessages: []))
private let messagesStatePromise = Promise<GroupCallMessagesContext.State>(GroupCallMessagesContext.State(messages: [], pinnedMessages: [], topStars: [], totalStars: 0))
public var messagesState: Signal<GroupCallMessagesContext.State, NoError> {
return self.messagesStatePromise.get()
}
@ -4061,6 +4061,12 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
}
}
public func sendStars(amount: Int64) {
if let messagesContext = self.messagesContext {
messagesContext.sendStars(fromId: self.joinAsPeerId, amount: amount)
}
}
public func deleteMessage(id: GroupCallMessagesContext.Message.Id) {
if let messagesContext = self.messagesContext {
messagesContext.deleteMessage(id: id)

View file

@ -3761,13 +3761,52 @@ public final class GroupCallMessagesContext {
}
}
public final class TopStarsItem: Equatable {
public let peer: EnginePeer?
public let amount: Int64
public let isTop: Bool
public let isMy: Bool
public let isAnonymous: Bool
public init(peer: EnginePeer?, amount: Int64, isTop: Bool, isMy: Bool, isAnonymous: Bool) {
self.peer = peer
self.amount = amount
self.isTop = isTop
self.isMy = isMy
self.isAnonymous = isAnonymous
}
public static func ==(lhs: TopStarsItem, rhs: TopStarsItem) -> Bool {
if lhs.peer != rhs.peer {
return false
}
if lhs.amount != rhs.amount {
return false
}
if lhs.isTop != rhs.isTop {
return false
}
if lhs.isMy != rhs.isMy {
return false
}
if lhs.isAnonymous != rhs.isAnonymous {
return false
}
return true
}
}
public struct State: Equatable {
public var messages: [Message]
public var pinnedMessages: [Message]
public var topStars: [TopStarsItem]
public var totalStars: Int64
public init(messages: [Message], pinnedMessages: [Message]) {
public init(messages: [Message], pinnedMessages: [Message], topStars: [TopStarsItem], totalStars: Int64) {
self.messages = messages
self.pinnedMessages = pinnedMessages
self.topStars = topStars
self.totalStars = totalStars
}
}
@ -3789,6 +3828,7 @@ public final class GroupCallMessagesContext {
let stateValue = ValuePromise<State>()
var updatesDisposable: Disposable?
var pollTopStarsDisposable: Disposable?
let sendMessageDisposables = DisposableSet()
var processedIds = Set<Int64>()
@ -3804,7 +3844,7 @@ public final class GroupCallMessagesContext {
self.messageLifetime = messageLifetime
self.isLiveStream = isLiveStream
self.state = State(messages: [], pinnedMessages: [])
self.state = State(messages: [], pinnedMessages: [], topStars: [], totalStars: 0)
self.stateValue.set(self.state)
self.updatesDisposable = (account.stateManager.groupCallMessageUpdates
@ -3913,10 +3953,13 @@ public final class GroupCallMessagesContext {
}
existingIds.insert(message.id)
state.messages.append(message)
if self.isLiveStream && message.paidStars != nil {
if self.isLiveStream, let paidStars = message.paidStars {
if message.date + message.lifetime >= currentTime {
state.pinnedMessages.append(message)
}
if let author = message.author {
Impl.addStateStars(state: &state, peer: author, isMy: false, amount: paidStars)
}
}
}
self.state = state
@ -3929,12 +3972,75 @@ public final class GroupCallMessagesContext {
}, queue: self.queue)
self.messageLifeTimer = timer
timer.start()
self.pollTopStars()
}
deinit {
self.updatesDisposable?.dispose()
self.sendMessageDisposables.dispose()
self.messageLifeTimer?.invalidate()
self.pollTopStarsDisposable?.dispose()
}
private func pollTopStars() {
let accountPeerId = self.account.peerId
let postbox = self.account.postbox
self.pollTopStarsDisposable?.dispose()
self.pollTopStarsDisposable = ((self.account.network.request(Api.functions.phone.getGroupCallStars(call: self.reference.apiInputGroupCall))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.phone.GroupCallStars?, NoError> in
return .single(nil)
}
|> then(Signal<Api.phone.GroupCallStars?, NoError>.complete() |> delay(30.0, queue: self.queue))) |> restart
|> mapToSignal { result -> Signal<(Api.phone.GroupCallStars, [PeerId: Peer])?, NoError> in
guard let result else {
return .single(nil)
}
return postbox.transaction { transaction -> (Api.phone.GroupCallStars, [PeerId: Peer])? in
var peers: [PeerId: Peer] = [:]
switch result {
case let .groupCallStars(_, topDonors, chats, users):
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(chats: chats, users: users))
for topDonor in topDonors {
switch topDonor {
case let .groupCallDonor(_, peerId, _):
if let peerId {
if peers[peerId.peerId] == nil, let peer = transaction.getPeer(peerId.peerId) {
peers[peer.id] = peer
}
}
}
}
}
return (result, peers)
}
}
|> deliverOn(self.queue)).startStrict(next: { [weak self] result in
guard let self else {
return
}
if let (result, peers) = result {
switch result {
case let .groupCallStars(totalStars, topDonors, _, _):
var state = self.state
state.topStars = topDonors.map { topDonor in
switch topDonor {
case let .groupCallDonor(flags, peerId, stars):
return TopStarsItem(
peer: peerId.flatMap { peers[$0.peerId].flatMap(EnginePeer.init) },
amount: stars,
isTop: (flags & (1 << 0)) != 0,
isMy: (flags & (1 << 1)) != 0,
isAnonymous: (flags & (1 << 2)) != 0
)
}
}
state.totalStars = totalStars
self.state = state
}
}
})
}
private func messageLifetimeTick() {
@ -3967,6 +4073,68 @@ public final class GroupCallMessagesContext {
}
}
static func addStateStars(state: inout State, peer: EnginePeer?, isMy: Bool, amount: Int64) {
state.totalStars += amount
var totalMyAmount: Int64 = amount
if let index = state.topStars.firstIndex(where: { $0.isMy }) {
totalMyAmount += state.topStars[index].amount
state.topStars[index] = TopStarsItem(
peer: peer,
amount: totalMyAmount,
isTop: false,
isMy: isMy,
isAnonymous: state.topStars[index].isAnonymous
)
} else {
state.topStars.append(TopStarsItem(
peer: peer,
amount: totalMyAmount,
isTop: false,
isMy: isMy,
isAnonymous: false
))
}
state.topStars.sort(by: { lhs, rhs in
if lhs.amount != rhs.amount {
return lhs.amount > rhs.amount
}
if let lhsPeer = lhs.peer, let rhsPeer = rhs.peer {
return lhsPeer.id < rhsPeer.id
}
if (lhs.peer == nil) != (rhs.peer == nil) {
return lhs.peer != nil
}
return !lhs.isAnonymous
})
if let index = state.topStars.firstIndex(where: { $0.isMy }) {
let item = state.topStars[index]
if index > 3 {
if isMy {
state.topStars[index] = TopStarsItem(
peer: item.peer,
amount: item.amount,
isTop: false,
isMy: true,
isAnonymous: item.isAnonymous
)
} else {
state.topStars.remove(at: index)
}
} else {
state.topStars[index] = TopStarsItem(
peer: item.peer,
amount: item.amount,
isTop: true,
isMy: true,
isAnonymous: item.isAnonymous
)
}
}
}
func send(fromId: EnginePeer.Id, randomId requestedRandomId: Int64?, text: String, entities: [MessageTextEntity], paidStars: Int64?) {
let _ = (self.account.postbox.transaction { transaction -> Peer? in
return transaction.getPeer(fromId)
@ -4004,19 +4172,13 @@ public final class GroupCallMessagesContext {
)
state.messages.append(message)
if self.isLiveStream {
if paidStars != nil {
if let paidStars {
state.pinnedMessages.append(message)
Impl.addStateStars(state: &state, peer: fromPeer.flatMap(EnginePeer.init), isMy: true, amount: paidStars)
}
}
self.state = state
#if DEBUG
var paidStars = paidStars
if "".isEmpty {
paidStars = nil
}
#endif
self.processedIds.insert(randomId)
if let e2eContext = self.e2eContext, let messageData = serializeGroupCallMessage(randomId: randomId, text: text, entities: entities) {
@ -4044,7 +4206,7 @@ public final class GroupCallMessagesContext {
flags |= 1 << 0
}
self.sendMessageDisposables.add((self.account.network.request(Api.functions.phone.sendGroupCallMessage(
flags: 0,
flags: flags,
call: self.reference.apiInputGroupCall,
randomId: randomId,
message: .textWithEntities(
@ -4080,6 +4242,96 @@ public final class GroupCallMessagesContext {
})
}
func sendStars(fromId: EnginePeer.Id, amount: Int64) {
let _ = (self.account.postbox.transaction { transaction -> Peer? in
return transaction.getPeer(fromId)
}
|> deliverOn(self.queue)).startStandalone(next: { [weak self] fromPeer in
guard let self else {
return
}
let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
var randomId: Int64 = 0
arc4random_buf(&randomId, 8)
let lifetime: Int32
lifetime = Int32(GroupCallMessagesContext.getStarAmountParamMapping(value: amount).period)
var state = self.state
let message = Message(
id: Message.Id(space: .local, id: randomId),
author: fromPeer.flatMap(EnginePeer.init),
text: "",
entities: [],
date: currentTime,
lifetime: lifetime,
paidStars: amount
)
state.messages.append(message)
if self.isLiveStream {
state.pinnedMessages.append(message)
Impl.addStateStars(state: &state, peer: fromPeer.flatMap(EnginePeer.init), isMy: true, amount: amount)
}
self.state = state
self.processedIds.insert(randomId)
if let e2eContext = self.e2eContext, let messageData = serializeGroupCallMessage(randomId: randomId, text: "", entities: []) {
let encryptedMessage = e2eContext.state.with({ state -> Data? in
guard let state = state.state else {
return nil
}
return state.encrypt(message: messageData, channelId: 2, plaintextPrefixLength: 0)
})
if let encryptedMessage {
self.sendMessageDisposables.add(self.account.network.request(Api.functions.phone.sendGroupCallEncryptedMessage(
call: self.reference.apiInputGroupCall,
encryptedMessage: Buffer(data: encryptedMessage)
)).startStrict())
}
} else {
var randomId: Int64 = 0
arc4random_buf(&randomId, 8)
var flags: Int32 = 0
flags |= 1 << 0
self.sendMessageDisposables.add((self.account.network.request(Api.functions.phone.sendGroupCallMessage(
flags: flags,
call: self.reference.apiInputGroupCall,
randomId: randomId,
message: .textWithEntities(
text: "",
entities: []
),
allowPaidStars: amount
)) |> deliverOn(self.queue)).startStrict(next: { [weak self] updates in
guard let self else {
return
}
self.account.stateManager.addUpdates(updates)
for update in updates.allUpdates {
if case let .updateMessageID(id, randomIdValue) = update {
if randomIdValue == randomId {
self.processedIds.insert(Int64(id))
var state = self.state
if let index = state.messages.firstIndex(where: { $0.id == Message.Id(space: .local, id: randomId) }) {
state.messages[index] = state.messages[index].withId(Message.Id(space: .remote, id: Int64(id)))
}
if let index = state.pinnedMessages.firstIndex(where: { $0.id == Message.Id(space: .local, id: randomId) }) {
state.pinnedMessages[index] = state.pinnedMessages[index].withId(Message.Id(space: .remote, id: Int64(id)))
}
self.state = state
break
}
}
}
}, error: { _ in
}))
}
})
}
func deleteMessage(id: Message.Id) {
var updatedState: State?
if let index = self.state.messages.firstIndex(where: { $0.id == id }) {
@ -4123,6 +4375,12 @@ public final class GroupCallMessagesContext {
}
}
public func sendStars(fromId: EnginePeer.Id, amount: Int64) {
self.impl.with { impl in
impl.sendStars(fromId: fromId, amount: amount)
}
}
public func deleteMessage(id: Message.Id) {
self.impl.with { impl in
impl.deleteMessage(id: id)

View file

@ -182,6 +182,16 @@ public final class MessageInputPanelComponent: Component {
}
}
public struct StarStats: Equatable {
public var myStars: Int64
public var totalStars: Int64
public init(myStars: Int64, totalStars: Int64) {
self.myStars = myStars
self.totalStars = totalStars
}
}
public let externalState: ExternalState
public let context: AccountContext
public let theme: PresentationTheme
@ -244,6 +254,7 @@ public final class MessageInputPanelComponent: Component {
public let liveChatState: LiveChatState?
public let toggleLiveChatExpanded: (() -> Void)?
public let sendStarsAction: ((UIView, Bool) -> Void)?
public let starStars: StarStats?
public init(
externalState: ExternalState,
@ -307,7 +318,8 @@ public final class MessageInputPanelComponent: Component {
chatLocation: ChatLocation?,
liveChatState: LiveChatState? = nil,
toggleLiveChatExpanded: (() -> Void)? = nil,
sendStarsAction: ((UIView, Bool) -> Void)? = nil
sendStarsAction: ((UIView, Bool) -> Void)? = nil,
starStars: StarStats? = nil
) {
self.externalState = externalState
self.context = context
@ -371,6 +383,7 @@ public final class MessageInputPanelComponent: Component {
self.liveChatState = liveChatState
self.toggleLiveChatExpanded = toggleLiveChatExpanded
self.sendStarsAction = sendStarsAction
self.starStars = starStars
}
public static func ==(lhs: MessageInputPanelComponent, rhs: MessageInputPanelComponent) -> Bool {
@ -503,6 +516,9 @@ public final class MessageInputPanelComponent: Component {
if lhs.liveChatState != rhs.liveChatState {
return false
}
if lhs.starStars != rhs.starStars {
return false
}
return true
}
@ -967,7 +983,7 @@ public final class MessageInputPanelComponent: Component {
}
component.toggleLiveChatExpanded?()
}),
rightAction: ChatTextInputPanelComponent.RightAction(kind: .stars(count: Int(component.storyItem?.views?.reactions.first(where: { $0.value == .stars })?.count ?? 0), isFilled: component.myReaction?.reaction == .stars), action: { [weak self] sourceView in
rightAction: ChatTextInputPanelComponent.RightAction(kind: .stars(count: Int(component.starStars?.totalStars ?? 0), isFilled: (component.starStars?.myStars ?? 0) != 0), action: { [weak self] sourceView in
guard let self, let component = self.component else {
return
}

View file

@ -446,6 +446,17 @@ final class StoryContentLiveChatComponent: Component {
}
private(set) var isChatExpanded: Bool = false
public var starStars: (myStars: Int64, totalStars: Int64)? {
guard let messagesState = self.messagesState else {
return nil
}
var myStars: Int64 = 0
if let item = messagesState.topStars.first(where: { $0.isMy }) {
myStars = item.amount
}
return (myStars, messagesState.totalStars)
}
override init(frame: CGRect) {
self.listContainer = UIView()
@ -506,7 +517,7 @@ final class StoryContentLiveChatComponent: Component {
self.addSubview(self.listShadowView)
self.addSubview(self.listContainer)
//self.isChatExpanded = true
self.isChatExpanded = true
}
required init?(coder: NSCoder) {

View file

@ -167,6 +167,13 @@ final class StoryItemContentComponent: Component {
)
}
public var starStars: (myStars: Int64, totalStars: Int64)? {
guard let liveChatView = self.liveChat?.view as? StoryContentLiveChatComponent.View else {
return nil
}
return liveChatView.starStars
}
public func toggleLiveChatExpanded() {
guard let liveChatView = self.liveChat?.view as? StoryContentLiveChatComponent.View else {
return

View file

@ -2964,6 +2964,7 @@ public final class StoryItemSetContainerComponent: Component {
}
var liveChatState: MessageInputPanelComponent.LiveChatState?
var starStats: MessageInputPanelComponent.StarStats?
if let visibleItemView = self.visibleItems[component.slice.item.id]?.view.view as? StoryItemContentComponent.View {
liveChatState = visibleItemView.liveChatState.flatMap { liveChatState in
return MessageInputPanelComponent.LiveChatState(
@ -2971,6 +2972,25 @@ public final class StoryItemSetContainerComponent: Component {
hasUnseenMessages: liveChatState.hasUnseenMessages
)
}
starStats = visibleItemView.starStars.flatMap { starStats in
return MessageInputPanelComponent.StarStats(
myStars: starStats.myStars,
totalStars: starStats.totalStars
)
}
}
if self.sendMessageContext.pendingLiveStreamSendStars != 0 {
if let starStatsValue = starStats {
starStats = MessageInputPanelComponent.StarStats(
myStars: starStatsValue.myStars + Int64(self.sendMessageContext.pendingLiveStreamSendStars),
totalStars: starStatsValue.totalStars + Int64(self.sendMessageContext.pendingLiveStreamSendStars)
)
} else {
starStats = MessageInputPanelComponent.StarStats(
myStars: Int64(self.sendMessageContext.pendingLiveStreamSendStars),
totalStars: Int64(self.sendMessageContext.pendingLiveStreamSendStars)
)
}
}
inputPanelSize = self.inputPanel.update(
@ -3220,7 +3240,8 @@ public final class StoryItemSetContainerComponent: Component {
} else {
self.sendMessageContext.performSendStars(view: self, buttonView: sourceView, count: 1, isFromExpandedView: false)
}
} : nil
} : nil,
starStars: starStats
)),
environment: {},
containerSize: CGSize(width: inputPanelAvailableWidth, height: 200.0)

View file

@ -102,6 +102,8 @@ final class StoryItemSetContainerSendMessage {
var currentSpeechHolder: SpeechSynthesizerHolder?
var currentLiveStreamMessageStars: StarsAmount?
var pendingLiveStreamSendStars: Int = 0
var pendingLiveStreamSendStarTimer: Foundation.Timer?
private(set) var isMediaRecordingLocked: Bool = false
var wasRecordingDismissed: Bool = false
@ -116,6 +118,7 @@ final class StoryItemSetContainerSendMessage {
self.resolvePeerByNameDisposable.dispose()
self.inputMediaNodeDataDisposable?.dispose()
self.currentTooltipUpdateTimer?.invalidate()
self.pendingLiveStreamSendStarTimer?.invalidate()
}
func setup(context: AccountContext, view: StoryItemSetContainerComponent.View, inputPanelExternalState: MessageInputPanelComponent.ExternalState, keyboardInputData: Signal<ChatEntityKeyboardInputNode.InputData, NoError>) {
@ -422,7 +425,7 @@ final class StoryItemSetContainerSendMessage {
return
}
self.currentLiveStreamMessageStars = nil
view.state?.updated(transition: .spring(duration: 0.3))
view.state?.updated(transition: .spring(duration: 0.4))
})))
}
} else {
@ -677,7 +680,7 @@ final class StoryItemSetContainerSendMessage {
self.currentInputMode = .text
self.currentLiveStreamMessageStars = nil
view.state?.updated(transition: .spring(duration: 0.3))
view.state?.updated(transition: .spring(duration: 0.4))
let controller = component.controller() as? StoryContainerScreen
controller?.requestLayout(forceUpdate: true, transition: .animated(duration: 0.3, curve: .spring))
@ -759,7 +762,7 @@ final class StoryItemSetContainerSendMessage {
if hasFirstResponder(view) {
view.endEditing(true)
} else {
view.state?.updated(transition: .spring(duration: 0.3))
view.state?.updated(transition: .spring(duration: 0.4))
}
controller?.requestLayout(forceUpdate: true, transition: .animated(duration: 0.3, curve: .spring))
}
@ -826,7 +829,7 @@ final class StoryItemSetContainerSendMessage {
if hasFirstResponder(view) {
view.endEditing(true)
} else {
view.state?.updated(transition: .spring(duration: 0.3))
view.state?.updated(transition: .spring(duration: 0.4))
}
controller?.requestLayout(forceUpdate: true, transition: .animated(duration: 0.3, curve: .spring))
})
@ -886,7 +889,7 @@ final class StoryItemSetContainerSendMessage {
if hasFirstResponder(view) {
view.endEditing(true)
} else {
view.state?.updated(transition: .spring(duration: 0.3))
view.state?.updated(transition: .spring(duration: 0.4))
}
controller?.requestLayout(forceUpdate: true, transition: .animated(duration: 0.3, curve: .spring))
})
@ -3912,11 +3915,49 @@ final class StoryItemSetContainerSendMessage {
}
func performSendStars(view: StoryItemSetContainerComponent.View, buttonView: UIView, count: Int, isFromExpandedView: Bool) {
self.pendingLiveStreamSendStars += count
if isFromExpandedView {
let totalCount = self.pendingLiveStreamSendStars
self.pendingLiveStreamSendStars = 0
self.pendingLiveStreamSendStarTimer?.invalidate()
self.pendingLiveStreamSendStarTimer = nil
self.commitSendStars(view: view, count: totalCount)
} else {
self.pendingLiveStreamSendStarTimer?.invalidate()
self.pendingLiveStreamSendStarTimer = nil
view.state?.updated(transition: .spring(duration: 0.4))
self.pendingLiveStreamSendStarTimer = Foundation.Timer.scheduledTimer(withTimeInterval: 5.0, repeats: false, block: { [weak self, weak view] _ in
guard let self, let view else {
return
}
let totalCount = self.pendingLiveStreamSendStars
self.pendingLiveStreamSendStars = 0
self.pendingLiveStreamSendStarTimer?.invalidate()
self.pendingLiveStreamSendStarTimer = nil
self.commitSendStars(view: view, count: totalCount)
})
}
}
private func commitSendStars(view: StoryItemSetContainerComponent.View, count: Int) {
guard let component = view.component else {
return
}
let _ = component.context.engine.messages.sendStoryStars(peerId: component.slice.effectivePeer.id, id: component.slice.item.storyItem.id, count: count).startStandalone()
guard case .liveStream = component.slice.item.storyItem.media else {
return
}
guard let visibleItem = view.visibleItems[component.slice.item.id], let itemView = visibleItem.view.view as? StoryItemContentComponent.View else {
return
}
guard let call = itemView.mediaStreamCall else {
return
}
call.sendStars(amount: Int64(count))
}
}