mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Group boosts
This commit is contained in:
@@ -129,7 +129,26 @@ func _internal_applyChannelBoost(account: Account, peerId: PeerId, slots: [Int32
|
||||
|> mapToSignal { result -> Signal<MyBoostStatus?, NoError> in
|
||||
if let result = result {
|
||||
return account.postbox.transaction { transaction -> MyBoostStatus? in
|
||||
return MyBoostStatus(apiMyBoostStatus: result, accountPeerId: account.peerId, transaction: transaction)
|
||||
let myBoostStatus = MyBoostStatus(apiMyBoostStatus: result, accountPeerId: account.peerId, transaction: transaction)
|
||||
|
||||
var appliedBoosts: Int32 = 0
|
||||
for boost in myBoostStatus.boosts {
|
||||
if boost.peer?.id == peerId {
|
||||
appliedBoosts += 1
|
||||
}
|
||||
}
|
||||
|
||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||
var cachedData: CachedChannelData
|
||||
if let current = current as? CachedChannelData {
|
||||
cachedData = current
|
||||
} else {
|
||||
cachedData = CachedChannelData()
|
||||
}
|
||||
return cachedData.withUpdatedAppliedBoosts(appliedBoosts)
|
||||
})
|
||||
|
||||
return myBoostStatus
|
||||
}
|
||||
} else {
|
||||
return .single(nil)
|
||||
|
||||
Reference in New Issue
Block a user