@@ -1459,10 +1459,10 @@ private final class ProfileGiftsContextImpl {
14591459 return _internal_transferStarGift ( account: self . account, prepaid: prepaid, reference: reference, peerId: peerId)
14601460 }
14611461
1462- func buyStarGift( reference : StarGiftReference , peerId: EnginePeer . Id ) -> Signal < Never , BuyStarGiftError > {
1463- var gift = self . gifts. first ( where: { $0. reference == reference } )
1462+ func buyStarGift( gift inputGift : TelegramCore . StarGift , peerId: EnginePeer . Id ) -> Signal < Never , BuyStarGiftError > {
1463+ var gift = self . gifts. first ( where: { $0. gift == inputGift } )
14641464 if gift == nil {
1465- gift = self . filteredGifts. first ( where: { $0. reference == reference } )
1465+ gift = self . filteredGifts. first ( where: { $0. gift == inputGift } )
14661466 }
14671467 guard case let . unique( uniqueGift) = gift? . gift else {
14681468 return . complete( )
@@ -1471,13 +1471,19 @@ private final class ProfileGiftsContextImpl {
14711471 if let count = self . count {
14721472 self . count = max ( 0 , count - 1 )
14731473 }
1474- self . gifts. removeAll ( where: { $0. reference == reference } )
1475- self . filteredGifts. removeAll ( where: { $0. reference == reference } )
1474+ self . gifts. removeAll ( where: { $0. gift == inputGift } )
1475+ self . filteredGifts. removeAll ( where: { $0. gift == inputGift } )
14761476 self . pushState ( )
14771477
14781478 return _internal_buyStarGift ( account: self . account, slug: uniqueGift. slug, peerId: peerId)
14791479 }
14801480
1481+ func removeStarGift( gift: TelegramCore . StarGift ) {
1482+ self . gifts. removeAll ( where: { $0. gift == gift } )
1483+ self . filteredGifts. removeAll ( where: { $0. gift == gift } )
1484+ self . pushState ( )
1485+ }
1486+
14811487 func upgradeStarGift( formId: Int64 ? , reference: StarGiftReference , keepOriginalInfo: Bool ) -> Signal < ProfileGiftsContext . State . StarGift , UpgradeStarGiftError > {
14821488 return Signal { [ weak self] subscriber in
14831489 guard let self else {
@@ -1893,11 +1899,11 @@ public final class ProfileGiftsContext {
18931899 }
18941900 }
18951901
1896- public func buyStarGift( reference : StarGiftReference , peerId: EnginePeer . Id ) -> Signal < Never , BuyStarGiftError > {
1902+ public func buyStarGift( gift : TelegramCore . StarGift , peerId: EnginePeer . Id ) -> Signal < Never , BuyStarGiftError > {
18971903 return Signal { subscriber in
18981904 let disposable = MetaDisposable ( )
18991905 self . impl. with { impl in
1900- disposable. set ( impl. buyStarGift ( reference : reference , peerId: peerId) . start ( error: { error in
1906+ disposable. set ( impl. buyStarGift ( gift : gift , peerId: peerId) . start ( error: { error in
19011907 subscriber. putError ( error)
19021908 } , completed: {
19031909 subscriber. putCompletion ( )
@@ -1907,6 +1913,12 @@ public final class ProfileGiftsContext {
19071913 }
19081914 }
19091915
1916+ public func removeStarGift( gift: TelegramCore . StarGift ) {
1917+ self . impl. with { impl in
1918+ impl. removeStarGift ( gift: gift)
1919+ }
1920+ }
1921+
19101922 public func transferStarGift( prepaid: Bool , reference: StarGiftReference , peerId: EnginePeer . Id ) -> Signal < Never , TransferStarGiftError > {
19111923 return Signal { subscriber in
19121924 let disposable = MetaDisposable ( )
0 commit comments