Skip to content

Commit 9f6c3a9

Browse files
committed
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
2 parents d5139b6 + 7482abf commit 9f6c3a9

File tree

1 file changed

+48
-3
lines changed

1 file changed

+48
-3
lines changed

submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,11 +1480,18 @@ private final class ProfileGiftsContextImpl {
14801480
}
14811481
return false
14821482
})
1483+
14831484
self.pushState()
14841485

14851486
return _internal_buyStarGift(account: self.account, slug: slug, peerId: peerId)
14861487
}
14871488

1489+
func removeStarGift(gift: TelegramCore.StarGift) {
1490+
self.gifts.removeAll(where: { $0.gift == gift })
1491+
self.filteredGifts.removeAll(where: { $0.gift == gift })
1492+
self.pushState()
1493+
}
1494+
14881495
func upgradeStarGift(formId: Int64?, reference: StarGiftReference, keepOriginalInfo: Bool) -> Signal<ProfileGiftsContext.State.StarGift, UpgradeStarGiftError> {
14891496
return Signal { [weak self] subscriber in
14901497
guard let self else {
@@ -1520,7 +1527,7 @@ private final class ProfileGiftsContextImpl {
15201527
}
15211528
}
15221529

1523-
func updateStarGiftResellPrice(reference: StarGiftReference, price: Int64?) -> Signal<Never, UpdateStarGiftPriceError> {
1530+
func updateStarGiftResellPrice(reference: StarGiftReference, price: Int64?, id: Int64?) -> Signal<Never, UpdateStarGiftPriceError> {
15241531
return Signal { [weak self] subscriber in
15251532
guard let self else {
15261533
return EmptyDisposable
@@ -1539,6 +1546,16 @@ private final class ProfileGiftsContextImpl {
15391546
if gift.reference == reference {
15401547
return true
15411548
}
1549+
switch gift.gift {
1550+
case .generic(let gift):
1551+
if gift.id == id {
1552+
return true
1553+
}
1554+
case .unique(let uniqueGift):
1555+
if uniqueGift.id == id {
1556+
return true
1557+
}
1558+
}
15421559
return false
15431560
}) {
15441561
if case let .unique(uniqueGift) = self.gifts[index].gift {
@@ -1552,6 +1569,16 @@ private final class ProfileGiftsContextImpl {
15521569
if gift.reference == reference {
15531570
return true
15541571
}
1572+
switch gift.gift {
1573+
case .generic(let gift):
1574+
if gift.id == id {
1575+
return true
1576+
}
1577+
case .unique(let uniqueGift):
1578+
if uniqueGift.id == id {
1579+
return true
1580+
}
1581+
}
15551582
return false
15561583
}) {
15571584
if case let .unique(uniqueGift) = self.filteredGifts[index].gift {
@@ -1935,6 +1962,12 @@ public final class ProfileGiftsContext {
19351962
}
19361963
}
19371964

1965+
public func removeStarGift(gift: TelegramCore.StarGift) {
1966+
self.impl.with { impl in
1967+
impl.removeStarGift(gift: gift)
1968+
}
1969+
}
1970+
19381971
public func transferStarGift(prepaid: Bool, reference: StarGiftReference, peerId: EnginePeer.Id) -> Signal<Never, TransferStarGiftError> {
19391972
return Signal { subscriber in
19401973
let disposable = MetaDisposable()
@@ -1965,11 +1998,11 @@ public final class ProfileGiftsContext {
19651998
}
19661999
}
19672000

1968-
public func updateStarGiftResellPrice(reference: StarGiftReference, price: Int64?) -> Signal<Never, UpdateStarGiftPriceError> {
2001+
public func updateStarGiftResellPrice(reference: StarGiftReference, price: Int64?, id: Int64? = nil) -> Signal<Never, UpdateStarGiftPriceError> {
19692002
return Signal { subscriber in
19702003
let disposable = MetaDisposable()
19712004
self.impl.with { impl in
1972-
disposable.set(impl.updateStarGiftResellPrice(reference: reference, price: price).start(error: { error in
2005+
disposable.set(impl.updateStarGiftResellPrice(reference: reference, price: price, id: id).start(error: { error in
19732006
subscriber.putError(error)
19742007
}, completed: {
19752008
subscriber.putCompletion()
@@ -2524,6 +2557,11 @@ private final class ResaleGiftsContextImpl {
25242557
self.loadMore()
25252558
}
25262559

2560+
func removeStarGift(gift: TelegramCore.StarGift) {
2561+
self.gifts.removeAll(where: { $0 == gift })
2562+
self.pushState()
2563+
}
2564+
25272565
func updateSorting(_ sorting: ResaleGiftsContext.Sorting) {
25282566
guard self.sorting != sorting else {
25292567
return
@@ -2710,6 +2748,13 @@ public final class ResaleGiftsContext {
27102748
return disposable
27112749
}
27122750
}
2751+
2752+
public func removeStarGift(gift: TelegramCore.StarGift) {
2753+
self.impl.with { impl in
2754+
impl.removeStarGift(gift: gift)
2755+
}
2756+
}
2757+
27132758

27142759
public var currentState: ResaleGiftsContext.State? {
27152760
var state: ResaleGiftsContext.State?

0 commit comments

Comments
 (0)