mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-30 07:00:49 +00:00
Merge commit '472bf7d3b1169a630e4347f5f33e3b6cb979ffc8'
This commit is contained in:
commit
3c31a513e1
@ -1345,6 +1345,7 @@ public protocol AccountContext: AnyObject {
|
||||
var wallpaperUploadManager: WallpaperUploadManager? { get }
|
||||
var inAppPurchaseManager: InAppPurchaseManager? { get }
|
||||
var starsContext: StarsContext? { get }
|
||||
var tonContext: StarsContext? { get }
|
||||
|
||||
var currentLimitsConfiguration: Atomic<LimitsConfiguration> { get }
|
||||
var currentContentSettings: Atomic<ContentSettings> { get }
|
||||
|
@ -1896,7 +1896,7 @@ public func channelStatsController(
|
||||
starsState.set(.single(nil) |> then(starsContext.state |> map(Optional.init)))
|
||||
|
||||
let revenueTransactions = RevenueStatsTransactionsContext(account: context.account, peerId: peerId)
|
||||
let starsTransactions = context.engine.payments.peerStarsTransactionsContext(subject: .peer(peerId), mode: .all)
|
||||
let starsTransactions = context.engine.payments.peerStarsTransactionsContext(subject: .peer(peerId: peerId, ton: false), mode: .all)
|
||||
starsTransactions.loadMore()
|
||||
|
||||
var dismissAllTooltipsImpl: (() -> Void)?
|
||||
|
@ -582,6 +582,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1456486804] = { return Api.MessageAction.parse_messageActionGiftCode($0) }
|
||||
dict[1818391802] = { return Api.MessageAction.parse_messageActionGiftPremium($0) }
|
||||
dict[1171632161] = { return Api.MessageAction.parse_messageActionGiftStars($0) }
|
||||
dict[-1465661799] = { return Api.MessageAction.parse_messageActionGiftTon($0) }
|
||||
dict[-1475391004] = { return Api.MessageAction.parse_messageActionGiveawayLaunch($0) }
|
||||
dict[-2015170219] = { return Api.MessageAction.parse_messageActionGiveawayResults($0) }
|
||||
dict[2047704898] = { return Api.MessageAction.parse_messageActionGroupCall($0) }
|
||||
@ -955,6 +956,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1242965043] = { return Api.StarGiftAttributeId.parse_starGiftAttributeIdPattern($0) }
|
||||
dict[-586389774] = { return Api.StarRefProgram.parse_starRefProgram($0) }
|
||||
dict[-1145654109] = { return Api.StarsAmount.parse_starsAmount($0) }
|
||||
dict[1957618656] = { return Api.StarsAmount.parse_starsTonAmount($0) }
|
||||
dict[1577421297] = { return Api.StarsGiftOption.parse_starsGiftOption($0) }
|
||||
dict[-1798404822] = { return Api.StarsGiveawayOption.parse_starsGiveawayOption($0) }
|
||||
dict[1411605001] = { return Api.StarsGiveawayWinnersOption.parse_starsGiveawayWinnersOption($0) }
|
||||
@ -1149,6 +1151,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-245208620] = { return Api.Update.parse_updateSmsJob($0) }
|
||||
dict[1317053305] = { return Api.Update.parse_updateStarsBalance($0) }
|
||||
dict[-1518030823] = { return Api.Update.parse_updateStarsRevenueStatus($0) }
|
||||
dict[-1944619808] = { return Api.Update.parse_updateStarsTonBalance($0) }
|
||||
dict[834816008] = { return Api.Update.parse_updateStickerSets($0) }
|
||||
dict[196268545] = { return Api.Update.parse_updateStickerSetsOrder($0) }
|
||||
dict[738741697] = { return Api.Update.parse_updateStoriesStealthMode($0) }
|
||||
|
@ -370,6 +370,7 @@ public extension Api {
|
||||
case messageActionGiftCode(flags: Int32, boostPeer: Api.Peer?, months: Int32, slug: String, currency: String?, amount: Int64?, cryptoCurrency: String?, cryptoAmount: Int64?, message: Api.TextWithEntities?)
|
||||
case messageActionGiftPremium(flags: Int32, currency: String, amount: Int64, months: Int32, cryptoCurrency: String?, cryptoAmount: Int64?, message: Api.TextWithEntities?)
|
||||
case messageActionGiftStars(flags: Int32, currency: String, amount: Int64, stars: Int64, cryptoCurrency: String?, cryptoAmount: Int64?, transactionId: String?)
|
||||
case messageActionGiftTon(flags: Int32, currency: String, amount: Int64, cryptoCurrency: String, cryptoAmount: Int64, transactionId: String?)
|
||||
case messageActionGiveawayLaunch(flags: Int32, stars: Int64?)
|
||||
case messageActionGiveawayResults(flags: Int32, winnersCount: Int32, unclaimedCount: Int32)
|
||||
case messageActionGroupCall(flags: Int32, call: Api.InputGroupCall, duration: Int32?)
|
||||
@ -579,6 +580,17 @@ public extension Api {
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt64(cryptoAmount!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeString(transactionId!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
case .messageActionGiftTon(let flags, let currency, let amount, let cryptoCurrency, let cryptoAmount, let transactionId):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1465661799)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeString(currency, buffer: buffer, boxed: false)
|
||||
serializeInt64(amount, buffer: buffer, boxed: false)
|
||||
serializeString(cryptoCurrency, buffer: buffer, boxed: false)
|
||||
serializeInt64(cryptoAmount, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeString(transactionId!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
case .messageActionGiveawayLaunch(let flags, let stars):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1475391004)
|
||||
@ -919,6 +931,8 @@ public extension Api {
|
||||
return ("messageActionGiftPremium", [("flags", flags as Any), ("currency", currency as Any), ("amount", amount as Any), ("months", months as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any), ("message", message as Any)])
|
||||
case .messageActionGiftStars(let flags, let currency, let amount, let stars, let cryptoCurrency, let cryptoAmount, let transactionId):
|
||||
return ("messageActionGiftStars", [("flags", flags as Any), ("currency", currency as Any), ("amount", amount as Any), ("stars", stars as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any), ("transactionId", transactionId as Any)])
|
||||
case .messageActionGiftTon(let flags, let currency, let amount, let cryptoCurrency, let cryptoAmount, let transactionId):
|
||||
return ("messageActionGiftTon", [("flags", flags as Any), ("currency", currency as Any), ("amount", amount as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any), ("transactionId", transactionId as Any)])
|
||||
case .messageActionGiveawayLaunch(let flags, let stars):
|
||||
return ("messageActionGiveawayLaunch", [("flags", flags as Any), ("stars", stars as Any)])
|
||||
case .messageActionGiveawayResults(let flags, let winnersCount, let unclaimedCount):
|
||||
@ -1306,6 +1320,32 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_messageActionGiftTon(_ reader: BufferReader) -> MessageAction? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: String?
|
||||
_2 = parseString(reader)
|
||||
var _3: Int64?
|
||||
_3 = reader.readInt64()
|
||||
var _4: String?
|
||||
_4 = parseString(reader)
|
||||
var _5: Int64?
|
||||
_5 = reader.readInt64()
|
||||
var _6: String?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_6 = parseString(reader) }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
let _c6 = (Int(_1!) & Int(1 << 0) == 0) || _6 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||
return Api.MessageAction.messageActionGiftTon(flags: _1!, currency: _2!, amount: _3!, cryptoCurrency: _4!, cryptoAmount: _5!, transactionId: _6)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_messageActionGiveawayLaunch(_ reader: BufferReader) -> MessageAction? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
|
@ -59,6 +59,7 @@ public extension Api {
|
||||
public extension Api {
|
||||
enum StarsAmount: TypeConstructorDescription {
|
||||
case starsAmount(amount: Int64, nanos: Int32)
|
||||
case starsTonAmount(amount: Int64)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -69,6 +70,12 @@ public extension Api {
|
||||
serializeInt64(amount, buffer: buffer, boxed: false)
|
||||
serializeInt32(nanos, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .starsTonAmount(let amount):
|
||||
if boxed {
|
||||
buffer.appendInt32(1957618656)
|
||||
}
|
||||
serializeInt64(amount, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,6 +83,8 @@ public extension Api {
|
||||
switch self {
|
||||
case .starsAmount(let amount, let nanos):
|
||||
return ("starsAmount", [("amount", amount as Any), ("nanos", nanos as Any)])
|
||||
case .starsTonAmount(let amount):
|
||||
return ("starsTonAmount", [("amount", amount as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,6 +102,17 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_starsTonAmount(_ reader: BufferReader) -> StarsAmount? {
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.StarsAmount.starsTonAmount(amount: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1294,153 +1314,3 @@ public extension Api {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum StickerSetCovered: TypeConstructorDescription {
|
||||
case stickerSetCovered(set: Api.StickerSet, cover: Api.Document)
|
||||
case stickerSetFullCovered(set: Api.StickerSet, packs: [Api.StickerPack], keywords: [Api.StickerKeyword], documents: [Api.Document])
|
||||
case stickerSetMultiCovered(set: Api.StickerSet, covers: [Api.Document])
|
||||
case stickerSetNoCovered(set: Api.StickerSet)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .stickerSetCovered(let set, let cover):
|
||||
if boxed {
|
||||
buffer.appendInt32(1678812626)
|
||||
}
|
||||
set.serialize(buffer, true)
|
||||
cover.serialize(buffer, true)
|
||||
break
|
||||
case .stickerSetFullCovered(let set, let packs, let keywords, let documents):
|
||||
if boxed {
|
||||
buffer.appendInt32(1087454222)
|
||||
}
|
||||
set.serialize(buffer, true)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(packs.count))
|
||||
for item in packs {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(keywords.count))
|
||||
for item in keywords {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(documents.count))
|
||||
for item in documents {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
case .stickerSetMultiCovered(let set, let covers):
|
||||
if boxed {
|
||||
buffer.appendInt32(872932635)
|
||||
}
|
||||
set.serialize(buffer, true)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(covers.count))
|
||||
for item in covers {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
case .stickerSetNoCovered(let set):
|
||||
if boxed {
|
||||
buffer.appendInt32(2008112412)
|
||||
}
|
||||
set.serialize(buffer, true)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .stickerSetCovered(let set, let cover):
|
||||
return ("stickerSetCovered", [("set", set as Any), ("cover", cover as Any)])
|
||||
case .stickerSetFullCovered(let set, let packs, let keywords, let documents):
|
||||
return ("stickerSetFullCovered", [("set", set as Any), ("packs", packs as Any), ("keywords", keywords as Any), ("documents", documents as Any)])
|
||||
case .stickerSetMultiCovered(let set, let covers):
|
||||
return ("stickerSetMultiCovered", [("set", set as Any), ("covers", covers as Any)])
|
||||
case .stickerSetNoCovered(let set):
|
||||
return ("stickerSetNoCovered", [("set", set as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_stickerSetCovered(_ reader: BufferReader) -> StickerSetCovered? {
|
||||
var _1: Api.StickerSet?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.StickerSet
|
||||
}
|
||||
var _2: Api.Document?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.Document
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.StickerSetCovered.stickerSetCovered(set: _1!, cover: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_stickerSetFullCovered(_ reader: BufferReader) -> StickerSetCovered? {
|
||||
var _1: Api.StickerSet?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.StickerSet
|
||||
}
|
||||
var _2: [Api.StickerPack]?
|
||||
if let _ = reader.readInt32() {
|
||||
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerPack.self)
|
||||
}
|
||||
var _3: [Api.StickerKeyword]?
|
||||
if let _ = reader.readInt32() {
|
||||
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerKeyword.self)
|
||||
}
|
||||
var _4: [Api.Document]?
|
||||
if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.StickerSetCovered.stickerSetFullCovered(set: _1!, packs: _2!, keywords: _3!, documents: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_stickerSetMultiCovered(_ reader: BufferReader) -> StickerSetCovered? {
|
||||
var _1: Api.StickerSet?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.StickerSet
|
||||
}
|
||||
var _2: [Api.Document]?
|
||||
if let _ = reader.readInt32() {
|
||||
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.StickerSetCovered.stickerSetMultiCovered(set: _1!, covers: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_stickerSetNoCovered(_ reader: BufferReader) -> StickerSetCovered? {
|
||||
var _1: Api.StickerSet?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.StickerSet
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.StickerSetCovered.stickerSetNoCovered(set: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
12045
submodules/TelegramApi/Sources/Api39.swift
Normal file
12045
submodules/TelegramApi/Sources/Api39.swift
Normal file
File diff suppressed because it is too large
Load Diff
@ -130,7 +130,7 @@ enum AccountStateMutationOperation {
|
||||
case UpdateNewAuthorization(isUnconfirmed: Bool, hash: Int64, date: Int32, device: String, location: String)
|
||||
case UpdateWallpaper(peerId: PeerId, wallpaper: TelegramWallpaper?)
|
||||
case UpdateRevenueBalances(peerId: PeerId, balances: RevenueStats.Balances)
|
||||
case UpdateStarsBalance(peerId: PeerId, balance: Api.StarsAmount)
|
||||
case UpdateStarsBalance(peerId: PeerId, ton: Bool, balance: Api.StarsAmount)
|
||||
case UpdateStarsRevenueStatus(peerId: PeerId, status: StarsRevenueStats.Balances)
|
||||
case UpdateStarsReactionsDefaultPrivacy(privacy: TelegramPaidReactionPrivacy)
|
||||
case ReportMessageDelivery([MessageId])
|
||||
@ -696,8 +696,8 @@ struct AccountMutableState {
|
||||
self.addOperation(.UpdateRevenueBalances(peerId: peerId, balances: balances))
|
||||
}
|
||||
|
||||
mutating func updateStarsBalance(peerId: PeerId, balance: Api.StarsAmount) {
|
||||
self.addOperation(.UpdateStarsBalance(peerId: peerId, balance: balance))
|
||||
mutating func updateStarsBalance(peerId: PeerId, ton: Bool, balance: Api.StarsAmount) {
|
||||
self.addOperation(.UpdateStarsBalance(peerId: peerId, ton: ton, balance: balance))
|
||||
}
|
||||
|
||||
mutating func updateStarsRevenueStatus(peerId: PeerId, status: StarsRevenueStats.Balances) {
|
||||
@ -860,6 +860,7 @@ struct AccountReplayedFinalState {
|
||||
let isPremiumUpdated: Bool
|
||||
let updatedRevenueBalances: [PeerId: RevenueStats.Balances]
|
||||
let updatedStarsBalance: [PeerId: StarsAmount]
|
||||
let updatedTonBalance: [PeerId: StarsAmount]
|
||||
let updatedStarsRevenueStatus: [PeerId: StarsRevenueStats.Balances]
|
||||
let sentScheduledMessageIds: Set<MessageId>
|
||||
let reportMessageDelivery: Set<MessageId>
|
||||
@ -893,15 +894,16 @@ struct AccountFinalStateEvents {
|
||||
let isPremiumUpdated: Bool
|
||||
let updatedRevenueBalances: [PeerId: RevenueStats.Balances]
|
||||
let updatedStarsBalance: [PeerId: StarsAmount]
|
||||
let updatedTonBalance: [PeerId: StarsAmount]
|
||||
let updatedStarsRevenueStatus: [PeerId: StarsRevenueStats.Balances]
|
||||
let reportMessageDelivery: Set<MessageId>
|
||||
let addedConferenceInvitationMessagesIds: [MessageId]
|
||||
|
||||
var isEmpty: Bool {
|
||||
return self.addedIncomingMessageIds.isEmpty && self.addedReactionEvents.isEmpty && self.wasScheduledMessageIds.isEmpty && self.deletedMessageIds.isEmpty && self.sentScheduledMessageIds.isEmpty && self.updatedTypingActivities.isEmpty && self.updatedWebpages.isEmpty && self.updatedCalls.isEmpty && self.addedCallSignalingData.isEmpty && self.updatedGroupCallParticipants.isEmpty && self.storyUpdates.isEmpty && self.updatedPeersNearby?.isEmpty ?? true && self.isContactUpdates.isEmpty && self.displayAlerts.isEmpty && self.dismissBotWebViews.isEmpty && self.delayNotificatonsUntil == nil && self.updatedMaxMessageId == nil && self.updatedQts == nil && self.externallyUpdatedPeerId.isEmpty && !authorizationListUpdated && self.updatedIncomingThreadReadStates.isEmpty && self.updatedOutgoingThreadReadStates.isEmpty && !self.updateConfig && !self.isPremiumUpdated && self.updatedRevenueBalances.isEmpty && self.updatedStarsBalance.isEmpty && self.updatedStarsRevenueStatus.isEmpty && self.reportMessageDelivery.isEmpty && self.addedConferenceInvitationMessagesIds.isEmpty
|
||||
return self.addedIncomingMessageIds.isEmpty && self.addedReactionEvents.isEmpty && self.wasScheduledMessageIds.isEmpty && self.deletedMessageIds.isEmpty && self.sentScheduledMessageIds.isEmpty && self.updatedTypingActivities.isEmpty && self.updatedWebpages.isEmpty && self.updatedCalls.isEmpty && self.addedCallSignalingData.isEmpty && self.updatedGroupCallParticipants.isEmpty && self.storyUpdates.isEmpty && self.updatedPeersNearby?.isEmpty ?? true && self.isContactUpdates.isEmpty && self.displayAlerts.isEmpty && self.dismissBotWebViews.isEmpty && self.delayNotificatonsUntil == nil && self.updatedMaxMessageId == nil && self.updatedQts == nil && self.externallyUpdatedPeerId.isEmpty && !authorizationListUpdated && self.updatedIncomingThreadReadStates.isEmpty && self.updatedOutgoingThreadReadStates.isEmpty && !self.updateConfig && !self.isPremiumUpdated && self.updatedRevenueBalances.isEmpty && self.updatedStarsBalance.isEmpty && self.updatedTonBalance.isEmpty && self.updatedStarsRevenueStatus.isEmpty && self.reportMessageDelivery.isEmpty && self.addedConferenceInvitationMessagesIds.isEmpty
|
||||
}
|
||||
|
||||
init(addedIncomingMessageIds: [MessageId] = [], addedReactionEvents: [(reactionAuthor: Peer, reaction: MessageReaction.Reaction, message: Message, timestamp: Int32)] = [], wasScheduledMessageIds: [MessageId] = [], deletedMessageIds: [DeletedMessageId] = [], updatedTypingActivities: [PeerActivitySpace: [PeerId: PeerInputActivity?]] = [:], updatedWebpages: [MediaId: TelegramMediaWebpage] = [:], updatedCalls: [Api.PhoneCall] = [], addedCallSignalingData: [(Int64, Data)] = [], updatedGroupCallParticipants: [(Int64, GroupCallParticipantsContext.Update)] = [], storyUpdates: [InternalStoryUpdate] = [], updatedPeersNearby: [PeerNearby]? = nil, isContactUpdates: [(PeerId, Bool)] = [], displayAlerts: [(text: String, isDropAuth: Bool)] = [], dismissBotWebViews: [Int64] = [], delayNotificatonsUntil: Int32? = nil, updatedMaxMessageId: Int32? = nil, updatedQts: Int32? = nil, externallyUpdatedPeerId: Set<PeerId> = Set(), authorizationListUpdated: Bool = false, updatedIncomingThreadReadStates: [PeerAndBoundThreadId: MessageId.Id] = [:], updatedOutgoingThreadReadStates: [PeerAndBoundThreadId: MessageId.Id] = [:], updateConfig: Bool = false, isPremiumUpdated: Bool = false, updatedRevenueBalances: [PeerId: RevenueStats.Balances] = [:], updatedStarsBalance: [PeerId: StarsAmount] = [:], updatedStarsRevenueStatus: [PeerId: StarsRevenueStats.Balances] = [:], sentScheduledMessageIds: Set<MessageId> = Set(), reportMessageDelivery: Set<MessageId> = Set(), addedConferenceInvitationMessagesIds: [MessageId] = []) {
|
||||
init(addedIncomingMessageIds: [MessageId] = [], addedReactionEvents: [(reactionAuthor: Peer, reaction: MessageReaction.Reaction, message: Message, timestamp: Int32)] = [], wasScheduledMessageIds: [MessageId] = [], deletedMessageIds: [DeletedMessageId] = [], updatedTypingActivities: [PeerActivitySpace: [PeerId: PeerInputActivity?]] = [:], updatedWebpages: [MediaId: TelegramMediaWebpage] = [:], updatedCalls: [Api.PhoneCall] = [], addedCallSignalingData: [(Int64, Data)] = [], updatedGroupCallParticipants: [(Int64, GroupCallParticipantsContext.Update)] = [], storyUpdates: [InternalStoryUpdate] = [], updatedPeersNearby: [PeerNearby]? = nil, isContactUpdates: [(PeerId, Bool)] = [], displayAlerts: [(text: String, isDropAuth: Bool)] = [], dismissBotWebViews: [Int64] = [], delayNotificatonsUntil: Int32? = nil, updatedMaxMessageId: Int32? = nil, updatedQts: Int32? = nil, externallyUpdatedPeerId: Set<PeerId> = Set(), authorizationListUpdated: Bool = false, updatedIncomingThreadReadStates: [PeerAndBoundThreadId: MessageId.Id] = [:], updatedOutgoingThreadReadStates: [PeerAndBoundThreadId: MessageId.Id] = [:], updateConfig: Bool = false, isPremiumUpdated: Bool = false, updatedRevenueBalances: [PeerId: RevenueStats.Balances] = [:], updatedStarsBalance: [PeerId: StarsAmount] = [:], updatedTonBalance: [PeerId: StarsAmount] = [:], updatedStarsRevenueStatus: [PeerId: StarsRevenueStats.Balances] = [:], sentScheduledMessageIds: Set<MessageId> = Set(), reportMessageDelivery: Set<MessageId> = Set(), addedConferenceInvitationMessagesIds: [MessageId] = []) {
|
||||
self.addedIncomingMessageIds = addedIncomingMessageIds
|
||||
self.addedReactionEvents = addedReactionEvents
|
||||
self.wasScheduledMessageIds = wasScheduledMessageIds
|
||||
@ -927,6 +929,7 @@ struct AccountFinalStateEvents {
|
||||
self.isPremiumUpdated = isPremiumUpdated
|
||||
self.updatedRevenueBalances = updatedRevenueBalances
|
||||
self.updatedStarsBalance = updatedStarsBalance
|
||||
self.updatedTonBalance = updatedTonBalance
|
||||
self.updatedStarsRevenueStatus = updatedStarsRevenueStatus
|
||||
self.sentScheduledMessageIds = sentScheduledMessageIds
|
||||
self.reportMessageDelivery = reportMessageDelivery
|
||||
@ -959,6 +962,7 @@ struct AccountFinalStateEvents {
|
||||
self.isPremiumUpdated = state.isPremiumUpdated
|
||||
self.updatedRevenueBalances = state.updatedRevenueBalances
|
||||
self.updatedStarsBalance = state.updatedStarsBalance
|
||||
self.updatedTonBalance = state.updatedTonBalance
|
||||
self.updatedStarsRevenueStatus = state.updatedStarsRevenueStatus
|
||||
self.sentScheduledMessageIds = state.sentScheduledMessageIds
|
||||
self.reportMessageDelivery = state.reportMessageDelivery
|
||||
@ -1025,6 +1029,7 @@ struct AccountFinalStateEvents {
|
||||
isPremiumUpdated: isPremiumUpdated,
|
||||
updatedRevenueBalances: self.updatedRevenueBalances.merging(other.updatedRevenueBalances, uniquingKeysWith: { lhs, _ in lhs }),
|
||||
updatedStarsBalance: self.updatedStarsBalance.merging(other.updatedStarsBalance, uniquingKeysWith: { lhs, _ in lhs }),
|
||||
updatedTonBalance: self.updatedTonBalance.merging(other.updatedTonBalance, uniquingKeysWith: { lhs, _ in lhs }),
|
||||
updatedStarsRevenueStatus: self.updatedStarsRevenueStatus.merging(other.updatedStarsRevenueStatus, uniquingKeysWith: { lhs, _ in lhs }),
|
||||
sentScheduledMessageIds: sentScheduledMessageIds,
|
||||
reportMessageDelivery: reportMessageDelivery,
|
||||
|
@ -232,7 +232,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
|
||||
}
|
||||
|
||||
switch action {
|
||||
case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionGiftStars, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionSetChatWallPaper, .messageActionGiveawayLaunch, .messageActionGiveawayResults, .messageActionBoostApply, .messageActionRequestedPeerSentMe, .messageActionStarGift, .messageActionStarGiftUnique, .messageActionPaidMessagesRefunded, .messageActionPaidMessagesPrice, .messageActionTodoCompletions, .messageActionTodoAppendTasks, .messageActionSuggestedPostApproval:
|
||||
case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionGiftStars, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionSetChatWallPaper, .messageActionGiveawayLaunch, .messageActionGiveawayResults, .messageActionBoostApply, .messageActionRequestedPeerSentMe, .messageActionStarGift, .messageActionStarGiftUnique, .messageActionPaidMessagesRefunded, .messageActionPaidMessagesPrice, .messageActionTodoCompletions, .messageActionTodoAppendTasks, .messageActionSuggestedPostApproval, .messageActionGiftTon:
|
||||
break
|
||||
case let .messageActionChannelMigrateFrom(_, chatId):
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)))
|
||||
|
@ -244,6 +244,8 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe
|
||||
status = .approved(timestamp: scheduleDate, amount: starsAmount ?? 0)
|
||||
}
|
||||
return TelegramMediaAction(action: .suggestedPostApprovalStatus(status: status))
|
||||
case let .messageActionGiftTon(_, currency, amount, cryptoCurrency, cryptoAmount, transactionId):
|
||||
return TelegramMediaAction(action: .giftTon(currency: currency, amount: amount, cryptoCurrency: cryptoCurrency, cryptoAmount: cryptoAmount, transactionId: transactionId))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1839,7 +1839,9 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
|
||||
case let .updateBroadcastRevenueTransactions(peer, balances):
|
||||
updatedState.updateRevenueBalances(peerId: peer.peerId, balances: RevenueStats.Balances(apiRevenueBalances: balances))
|
||||
case let .updateStarsBalance(balance):
|
||||
updatedState.updateStarsBalance(peerId: accountPeerId, balance: balance)
|
||||
updatedState.updateStarsBalance(peerId: accountPeerId, ton: false, balance: balance)
|
||||
case let .updateStarsTonBalance(balance):
|
||||
updatedState.updateStarsBalance(peerId: accountPeerId, ton: true, balance: balance)
|
||||
case let .updateStarsRevenueStatus(peer, status):
|
||||
updatedState.updateStarsRevenueStatus(peerId: peer.peerId, status: StarsRevenueStats.Balances(apiStarsRevenueStatus: status))
|
||||
case let .updatePaidReactionPrivacy(privacy):
|
||||
@ -3717,6 +3719,7 @@ func replayFinalState(
|
||||
var updateConfig = false
|
||||
var updatedRevenueBalances: [PeerId: RevenueStats.Balances] = [:]
|
||||
var updatedStarsBalance: [PeerId: StarsAmount] = [:]
|
||||
var updatedTonBalance: [PeerId: StarsAmount] = [:]
|
||||
var updatedStarsRevenueStatus: [PeerId: StarsRevenueStats.Balances] = [:]
|
||||
var updatedStarsReactionsDefaultPrivacy: TelegramPaidReactionPrivacy?
|
||||
var reportMessageDelivery = Set<MessageId>()
|
||||
@ -5169,8 +5172,12 @@ func replayFinalState(
|
||||
}
|
||||
case let .UpdateRevenueBalances(peerId, balances):
|
||||
updatedRevenueBalances[peerId] = balances
|
||||
case let .UpdateStarsBalance(peerId, balance):
|
||||
updatedStarsBalance[peerId] = StarsAmount(apiAmount: balance)
|
||||
case let .UpdateStarsBalance(peerId, ton, balance):
|
||||
if ton {
|
||||
updatedTonBalance[peerId] = StarsAmount(apiAmount: balance)
|
||||
} else {
|
||||
updatedStarsBalance[peerId] = StarsAmount(apiAmount: balance)
|
||||
}
|
||||
case let .UpdateStarsRevenueStatus(peerId, status):
|
||||
updatedStarsRevenueStatus[peerId] = status
|
||||
case let .UpdateStarsReactionsDefaultPrivacy(value):
|
||||
@ -5697,6 +5704,7 @@ func replayFinalState(
|
||||
isPremiumUpdated: isPremiumUpdated,
|
||||
updatedRevenueBalances: updatedRevenueBalances,
|
||||
updatedStarsBalance: updatedStarsBalance,
|
||||
updatedTonBalance: updatedTonBalance,
|
||||
updatedStarsRevenueStatus: updatedStarsRevenueStatus,
|
||||
sentScheduledMessageIds: finalState.state.sentScheduledMessageIds,
|
||||
reportMessageDelivery: reportMessageDelivery,
|
||||
|
@ -355,6 +355,7 @@ public final class AccountStateManager {
|
||||
private var updatedPeersNearbyContext = UpdatedPeersNearbySubscriberContext()
|
||||
private var updatedRevenueBalancesContext = UpdatedRevenueBalancesSubscriberContext()
|
||||
private var updatedStarsBalanceContext = UpdatedStarsBalanceSubscriberContext()
|
||||
private var updatedTonBalanceContext = UpdatedStarsBalanceSubscriberContext()
|
||||
private var updatedStarsRevenueStatusContext = UpdatedStarsRevenueStatusSubscriberContext()
|
||||
|
||||
private let delayNotificatonsUntil = Atomic<Int32?>(value: nil)
|
||||
@ -1117,6 +1118,9 @@ public final class AccountStateManager {
|
||||
if !events.updatedStarsBalance.isEmpty {
|
||||
strongSelf.notifyUpdatedStarsBalance(events.updatedStarsBalance)
|
||||
}
|
||||
if !events.updatedTonBalance.isEmpty {
|
||||
strongSelf.notifyUpdatedTonBalance(events.updatedTonBalance)
|
||||
}
|
||||
if !events.updatedStarsRevenueStatus.isEmpty {
|
||||
strongSelf.notifyUpdatedStarsRevenueStatus(events.updatedStarsRevenueStatus)
|
||||
}
|
||||
@ -1751,12 +1755,39 @@ public final class AccountStateManager {
|
||||
return disposable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func notifyUpdatedStarsBalance(_ updatedStarsBalance: [PeerId: StarsAmount]) {
|
||||
for subscriber in self.updatedStarsBalanceContext.subscribers.copyItems() {
|
||||
subscriber(updatedStarsBalance)
|
||||
}
|
||||
}
|
||||
|
||||
public func updatedTonBalance() -> Signal<[PeerId: StarsAmount], NoError> {
|
||||
let queue = self.queue
|
||||
return Signal { [weak self] subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
queue.async {
|
||||
if let strongSelf = self {
|
||||
let index = strongSelf.updatedTonBalanceContext.subscribers.add({ starsBalance in
|
||||
subscriber.putNext(starsBalance)
|
||||
})
|
||||
|
||||
disposable.set(ActionDisposable {
|
||||
if let strongSelf = self {
|
||||
strongSelf.updatedTonBalanceContext.subscribers.remove(index)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
return disposable
|
||||
}
|
||||
}
|
||||
|
||||
private func notifyUpdatedTonBalance(_ updatedTonBalance: [PeerId: StarsAmount]) {
|
||||
for subscriber in self.updatedTonBalanceContext.subscribers.copyItems() {
|
||||
subscriber(updatedTonBalance)
|
||||
}
|
||||
}
|
||||
|
||||
public func updatedStarsRevenueStatus() -> Signal<[PeerId: StarsRevenueStats.Balances], NoError> {
|
||||
let queue = self.queue
|
||||
@ -2007,6 +2038,7 @@ public final class AccountStateManager {
|
||||
let messagesRemovedContext = MessagesRemovedContext()
|
||||
|
||||
public weak var starsContext: StarsContext?
|
||||
public weak var tonContext: StarsContext?
|
||||
|
||||
init(
|
||||
accountPeerId: PeerId,
|
||||
@ -2145,6 +2177,12 @@ public final class AccountStateManager {
|
||||
}
|
||||
}
|
||||
|
||||
public func updatedTonBalance() -> Signal<[PeerId: StarsAmount], NoError> {
|
||||
return self.impl.signalWith { impl, subscriber in
|
||||
return impl.updatedStarsBalance().start(next: subscriber.putNext, error: subscriber.putError, completed: subscriber.putCompletion)
|
||||
}
|
||||
}
|
||||
|
||||
public func updatedStarsRevenueStatus() -> Signal<[PeerId: StarsRevenueStats.Balances], NoError> {
|
||||
return self.impl.signalWith { impl, subscriber in
|
||||
return impl.updatedStarsRevenueStatus().start(next: subscriber.putNext, error: subscriber.putError, completed: subscriber.putCompletion)
|
||||
|
@ -225,6 +225,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
case todoCompletions(completed: [Int32], incompleted: [Int32])
|
||||
case todoAppendTasks([TelegramMediaTodo.Item])
|
||||
case suggestedPostApprovalStatus(status: SuggestedPostApprovalStatus)
|
||||
case giftTon(currency: String, amount: Int64, cryptoCurrency: String?, cryptoAmount: Int64?, transactionId: String?)
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0)
|
||||
@ -372,6 +373,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
case 51:
|
||||
let status: SuggestedPostApprovalStatus? = decoder.decodeObjectForKey("st", decoder: { SuggestedPostApprovalStatus(decoder: $0) }) as? SuggestedPostApprovalStatus
|
||||
self = .suggestedPostApprovalStatus(status: status ?? .rejected(reason: .generic, comment: nil))
|
||||
case 52:
|
||||
self = .giftTon(currency: decoder.decodeStringForKey("currency", orElse: ""), amount: decoder.decodeInt64ForKey("amount", orElse: 0), cryptoCurrency: decoder.decodeOptionalStringForKey("cryptoCurrency"), cryptoAmount: decoder.decodeOptionalInt64ForKey("cryptoAmount"), transactionId: decoder.decodeOptionalStringForKey("transactionId"))
|
||||
default:
|
||||
self = .unknown
|
||||
}
|
||||
@ -785,6 +788,22 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
case let .suggestedPostApprovalStatus(status):
|
||||
encoder.encodeInt32(51, forKey: "_rawValue")
|
||||
encoder.encodeObject(status, forKey: "st")
|
||||
case let .giftTon(currency, amount, cryptoCurrency, cryptoAmount, transactionId):
|
||||
encoder.encodeInt32(52, forKey: "_rawValue")
|
||||
encoder.encodeString(currency, forKey: "currency")
|
||||
encoder.encodeInt64(amount, forKey: "amount")
|
||||
if let cryptoCurrency = cryptoCurrency, let cryptoAmount = cryptoAmount {
|
||||
encoder.encodeString(cryptoCurrency, forKey: "cryptoCurrency")
|
||||
encoder.encodeInt64(cryptoAmount, forKey: "cryptoAmount")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "cryptoCurrency")
|
||||
encoder.encodeNil(forKey: "cryptoAmount")
|
||||
}
|
||||
if let transactionId {
|
||||
encoder.encodeString(transactionId, forKey: "transactionId")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "transactionId")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -348,6 +348,8 @@ extension StarsAmount {
|
||||
switch apiAmount {
|
||||
case let .starsAmount(amount, nanos):
|
||||
self.init(value: amount, nanos: nanos)
|
||||
case let .starsTonAmount(amount):
|
||||
self.init(value: amount, nanos: 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -397,7 +399,7 @@ private enum RequestStarsStateError {
|
||||
case generic
|
||||
}
|
||||
|
||||
private func _internal_requestStarsState(account: Account, peerId: EnginePeer.Id, mode: StarsTransactionsContext.Mode, subscriptionId: String?, offset: String?, limit: Int32) -> Signal<InternalStarsStatus, RequestStarsStateError> {
|
||||
private func _internal_requestStarsState(account: Account, peerId: EnginePeer.Id, ton: Bool, mode: StarsTransactionsContext.Mode, subscriptionId: String?, offset: String?, limit: Int32) -> Signal<InternalStarsStatus, RequestStarsStateError> {
|
||||
return account.postbox.transaction { transaction -> Peer? in
|
||||
return transaction.getPeer(peerId)
|
||||
}
|
||||
@ -421,9 +423,16 @@ private func _internal_requestStarsState(account: Account, peerId: EnginePeer.Id
|
||||
if let _ = subscriptionId {
|
||||
flags = 1 << 3
|
||||
}
|
||||
if ton {
|
||||
flags = 1 << 4
|
||||
}
|
||||
signal = account.network.request(Api.functions.payments.getStarsTransactions(flags: flags, subscriptionId: subscriptionId, peer: inputPeer, offset: offset, limit: limit))
|
||||
} else {
|
||||
signal = account.network.request(Api.functions.payments.getStarsStatus(peer: inputPeer))
|
||||
var flags: Int32 = 0
|
||||
if ton {
|
||||
flags = 1 << 0
|
||||
}
|
||||
signal = account.network.request(Api.functions.payments.getStarsStatus(flags: flags, peer: inputPeer))
|
||||
}
|
||||
|
||||
return signal
|
||||
@ -517,6 +526,7 @@ private func _internal_requestStarsSubscriptions(account: Account, peerId: Engin
|
||||
private final class StarsContextImpl {
|
||||
private let account: Account
|
||||
fileprivate let peerId: EnginePeer.Id
|
||||
fileprivate let ton: Bool
|
||||
|
||||
fileprivate var _state: StarsContext.State?
|
||||
private let _statePromise = Promise<StarsContext.State?>()
|
||||
@ -527,11 +537,12 @@ private final class StarsContextImpl {
|
||||
private let disposable = MetaDisposable()
|
||||
private var updateDisposable: Disposable?
|
||||
|
||||
init(account: Account) {
|
||||
init(account: Account, ton: Bool) {
|
||||
assert(Queue.mainQueue().isCurrent())
|
||||
|
||||
self.account = account
|
||||
self.peerId = account.peerId
|
||||
self.ton = ton
|
||||
|
||||
self._state = nil
|
||||
self._statePromise.set(.single(nil))
|
||||
@ -564,7 +575,7 @@ private final class StarsContextImpl {
|
||||
}
|
||||
self.previousLoadTimestamp = currentTimestamp
|
||||
|
||||
self.disposable.set((_internal_requestStarsState(account: self.account, peerId: self.peerId, mode: .all, subscriptionId: nil, offset: nil, limit: 5)
|
||||
self.disposable.set((_internal_requestStarsState(account: self.account, peerId: self.peerId, ton: self.ton, mode: .all, subscriptionId: nil, offset: nil, limit: 5)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] status in
|
||||
guard let self else {
|
||||
return
|
||||
@ -1042,6 +1053,14 @@ public final class StarsContext {
|
||||
return peerId!
|
||||
}
|
||||
|
||||
var ton: Bool {
|
||||
var ton = false
|
||||
self.impl.syncWith { impl in
|
||||
ton = impl.ton
|
||||
}
|
||||
return ton
|
||||
}
|
||||
|
||||
public var currentState: StarsContext.State? {
|
||||
var state: StarsContext.State?
|
||||
self.impl.syncWith { impl in
|
||||
@ -1081,9 +1100,9 @@ public final class StarsContext {
|
||||
}
|
||||
}
|
||||
|
||||
init(account: Account) {
|
||||
init(account: Account, ton: Bool) {
|
||||
self.impl = QueueLocalObject(queue: Queue.mainQueue(), generate: {
|
||||
return StarsContextImpl(account: account)
|
||||
return StarsContextImpl(account: account, ton: ton)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1092,6 +1111,7 @@ private final class StarsTransactionsContextImpl {
|
||||
private let account: Account
|
||||
private weak var starsContext: StarsContext?
|
||||
fileprivate let peerId: EnginePeer.Id
|
||||
fileprivate let ton: Bool
|
||||
private let mode: StarsTransactionsContext.Mode
|
||||
|
||||
fileprivate var _state: StarsTransactionsContext.State
|
||||
@ -1107,20 +1127,22 @@ private final class StarsTransactionsContextImpl {
|
||||
init(account: Account, subject: StarsTransactionsContext.Subject, mode: StarsTransactionsContext.Mode) {
|
||||
assert(Queue.mainQueue().isCurrent())
|
||||
|
||||
|
||||
let currentTransactions: [StarsContext.State.Transaction]
|
||||
|
||||
self.account = account
|
||||
switch subject {
|
||||
case let .starsTransactionsContext(transactionsContext):
|
||||
self.peerId = transactionsContext.peerId
|
||||
self.ton = transactionsContext.ton
|
||||
currentTransactions = transactionsContext.currentState?.transactions ?? []
|
||||
case let .starsContext(starsContext):
|
||||
self.starsContext = starsContext
|
||||
self.peerId = starsContext.peerId
|
||||
self.ton = starsContext.ton
|
||||
currentTransactions = starsContext.currentState?.transactions ?? []
|
||||
case let .peer(peerId):
|
||||
case let .peer(peerId, ton):
|
||||
self.peerId = peerId
|
||||
self.ton = ton
|
||||
currentTransactions = []
|
||||
}
|
||||
self.mode = mode
|
||||
@ -1224,7 +1246,7 @@ private final class StarsTransactionsContextImpl {
|
||||
updatedState.isLoading = true
|
||||
self.updateState(updatedState)
|
||||
|
||||
self.disposable.set((_internal_requestStarsState(account: self.account, peerId: self.peerId, mode: self.mode, subscriptionId: nil, offset: nextOffset, limit: self.nextOffset == "" ? 25 : 50)
|
||||
self.disposable.set((_internal_requestStarsState(account: self.account, peerId: self.peerId, ton: self.ton, mode: self.mode, subscriptionId: nil, offset: nextOffset, limit: self.nextOffset == "" ? 25 : 50)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] status in
|
||||
guard let self else {
|
||||
return
|
||||
@ -1269,7 +1291,7 @@ public final class StarsTransactionsContext {
|
||||
public enum Subject {
|
||||
case starsTransactionsContext(StarsTransactionsContext)
|
||||
case starsContext(StarsContext)
|
||||
case peer(EnginePeer.Id)
|
||||
case peer(peerId: EnginePeer.Id, ton: Bool)
|
||||
}
|
||||
|
||||
public enum Mode {
|
||||
@ -1323,6 +1345,14 @@ public final class StarsTransactionsContext {
|
||||
}
|
||||
return peerId!
|
||||
}
|
||||
|
||||
var ton: Bool {
|
||||
var ton = false
|
||||
self.impl.syncWith { impl in
|
||||
ton = impl.ton
|
||||
}
|
||||
return ton
|
||||
}
|
||||
}
|
||||
|
||||
private final class StarsSubscriptionsContextImpl {
|
||||
|
@ -79,7 +79,11 @@ public extension TelegramEngine {
|
||||
}
|
||||
|
||||
public func peerStarsContext() -> StarsContext {
|
||||
return StarsContext(account: self.account)
|
||||
return StarsContext(account: self.account, ton: false)
|
||||
}
|
||||
|
||||
public func peerTonContext() -> StarsContext {
|
||||
return StarsContext(account: self.account, ton: true)
|
||||
}
|
||||
|
||||
public func peerStarsRevenueContext(peerId: EnginePeer.Id) -> StarsRevenueStatsContext {
|
||||
|
@ -1443,6 +1443,28 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
|
||||
}
|
||||
}
|
||||
attributedString = NSAttributedString(string: string, font: titleFont, textColor: primaryTextColor)
|
||||
case let .giftTon(currency, amount, _, _, _):
|
||||
let _ = currency
|
||||
let _ = amount
|
||||
attributedString = nil
|
||||
// if !forAdditionalServiceMessage {
|
||||
// attributedString = NSAttributedString(string: strings.Notification_Gift, font: titleFont, textColor: primaryTextColor)
|
||||
// } else {
|
||||
// let price = formatCurrencyAmount(amount, currency: currency)
|
||||
// if message.author?.id == accountPeerId {
|
||||
// attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_SentYou(price)._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
|
||||
// } else {
|
||||
// var authorName = compactAuthorName
|
||||
// var peerIds: [(Int, EnginePeer.Id?)] = [(0, message.author?.id)]
|
||||
// if message.id.peerId.namespace == Namespaces.Peer.CloudUser && message.id.peerId.id._internalGetInt64Value() == 777000 {
|
||||
// authorName = strings.Notification_StarsGift_UnknownUser
|
||||
// peerIds = []
|
||||
// }
|
||||
// var attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
|
||||
// attributes[1] = boldAttributes
|
||||
// attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Sent(authorName, price)._tuple, body: bodyAttributes, argumentAttributes: attributes)
|
||||
// }
|
||||
// }
|
||||
case .unknown:
|
||||
attributedString = nil
|
||||
}
|
||||
|
@ -710,7 +710,7 @@ final class StarsStatisticsScreenComponent: Component {
|
||||
if let current = self.allTransactionsContext {
|
||||
allTransactionsContext = current
|
||||
} else {
|
||||
allTransactionsContext = component.context.engine.payments.peerStarsTransactionsContext(subject: .peer(component.peerId), mode: .all)
|
||||
allTransactionsContext = component.context.engine.payments.peerStarsTransactionsContext(subject: .peer(peerId: component.peerId, ton: false), mode: .all)
|
||||
self.allTransactionsContext = allTransactionsContext
|
||||
}
|
||||
|
||||
|
@ -128,6 +128,7 @@ public final class AccountContextImpl: AccountContext {
|
||||
private let themeUpdateManager: ThemeUpdateManager?
|
||||
public let inAppPurchaseManager: InAppPurchaseManager?
|
||||
public let starsContext: StarsContext?
|
||||
public let tonContext: StarsContext?
|
||||
|
||||
public let peerChannelMemberCategoriesContextsManager = PeerChannelMemberCategoriesContextsManager()
|
||||
|
||||
@ -298,15 +299,18 @@ public final class AccountContextImpl: AccountContext {
|
||||
|
||||
self.inAppPurchaseManager = InAppPurchaseManager(engine: .authorized(self.engine))
|
||||
self.starsContext = self.engine.payments.peerStarsContext()
|
||||
self.tonContext = self.engine.payments.peerTonContext()
|
||||
} else {
|
||||
self.prefetchManager = nil
|
||||
self.wallpaperUploadManager = nil
|
||||
self.themeUpdateManager = nil
|
||||
self.inAppPurchaseManager = nil
|
||||
self.starsContext = nil
|
||||
self.tonContext = nil
|
||||
}
|
||||
|
||||
self.account.stateManager.starsContext = self.starsContext
|
||||
self.account.stateManager.tonContext = self.starsContext
|
||||
|
||||
self.peersNearbyManager = nil
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user