mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix
This commit is contained in:
parent
86930f1a7e
commit
ffed4a5e32
@ -1459,23 +1459,25 @@ private final class ProfileGiftsContextImpl {
|
|||||||
return _internal_transferStarGift(account: self.account, prepaid: prepaid, reference: reference, peerId: peerId)
|
return _internal_transferStarGift(account: self.account, prepaid: prepaid, reference: reference, peerId: peerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buyStarGift(reference: StarGiftReference, peerId: EnginePeer.Id) -> Signal<Never, BuyStarGiftError> {
|
func buyStarGift(slug: String, peerId: EnginePeer.Id) -> Signal<Never, BuyStarGiftError> {
|
||||||
var gift = self.gifts.first(where: { $0.reference == reference })
|
|
||||||
if gift == nil {
|
|
||||||
gift = self.filteredGifts.first(where: { $0.reference == reference })
|
|
||||||
}
|
|
||||||
guard case let .unique(uniqueGift) = gift?.gift else {
|
|
||||||
return .complete()
|
|
||||||
}
|
|
||||||
|
|
||||||
if let count = self.count {
|
if let count = self.count {
|
||||||
self.count = max(0, count - 1)
|
self.count = max(0, count - 1)
|
||||||
}
|
}
|
||||||
self.gifts.removeAll(where: { $0.reference == reference })
|
self.gifts.removeAll(where: { gift in
|
||||||
self.filteredGifts.removeAll(where: { $0.reference == reference })
|
if case let .unique(uniqueGift) = gift.gift, uniqueGift.slug == slug {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
self.filteredGifts.removeAll(where: { gift in
|
||||||
|
if case let .unique(uniqueGift) = gift.gift, uniqueGift.slug == slug {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
self.pushState()
|
self.pushState()
|
||||||
|
|
||||||
return _internal_buyStarGift(account: self.account, slug: uniqueGift.slug, peerId: peerId)
|
return _internal_buyStarGift(account: self.account, slug: slug, peerId: peerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func upgradeStarGift(formId: Int64?, reference: StarGiftReference, keepOriginalInfo: Bool) -> Signal<ProfileGiftsContext.State.StarGift, UpgradeStarGiftError> {
|
func upgradeStarGift(formId: Int64?, reference: StarGiftReference, keepOriginalInfo: Bool) -> Signal<ProfileGiftsContext.State.StarGift, UpgradeStarGiftError> {
|
||||||
@ -1893,11 +1895,11 @@ public final class ProfileGiftsContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func buyStarGift(reference: StarGiftReference, peerId: EnginePeer.Id) -> Signal<Never, BuyStarGiftError> {
|
public func buyStarGift(slug: String, peerId: EnginePeer.Id) -> Signal<Never, BuyStarGiftError> {
|
||||||
return Signal { subscriber in
|
return Signal { subscriber in
|
||||||
let disposable = MetaDisposable()
|
let disposable = MetaDisposable()
|
||||||
self.impl.with { impl in
|
self.impl.with { impl in
|
||||||
disposable.set(impl.buyStarGift(reference: reference, peerId: peerId).start(error: { error in
|
disposable.set(impl.buyStarGift(slug: slug, peerId: peerId).start(error: { error in
|
||||||
subscriber.putError(error)
|
subscriber.putError(error)
|
||||||
}, completed: {
|
}, completed: {
|
||||||
subscriber.putCompletion()
|
subscriber.putCompletion()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user