Skip to content

Commit 49a0605

Browse files
author
Isaac
committed
Merge commit '0a5c043896d641e281476420f561216809608be5'
2 parents 1f841d4 + 0a5c043 commit 49a0605

File tree

14 files changed

+175
-100
lines changed

14 files changed

+175
-100
lines changed

submodules/AccountContext/Sources/AccountContext.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,8 +1423,8 @@ public protocol SharedAccountContext: AnyObject {
14231423
func makeGiftViewScreen(context: AccountContext, gift: StarGift.UniqueGift, shareStory: ((StarGift.UniqueGift) -> Void)?, openChatTheme: (() -> Void)?, dismissed: (() -> Void)?) -> ViewController
14241424
func makeGiftWearPreviewScreen(context: AccountContext, gift: StarGift.UniqueGift) -> ViewController
14251425
func makeGiftAuctionInfoScreen(context: AccountContext, auctionContext: GiftAuctionContext, completion: (() -> Void)?) -> ViewController
1426-
func makeGiftAuctionBidScreen(context: AccountContext, toPeerId: EnginePeer.Id, text: String?, entities: [MessageTextEntity]?, hideName: Bool, auctionContext: GiftAuctionContext) -> ViewController
1427-
func makeGiftAuctionViewScreen(context: AccountContext, auctionContext: GiftAuctionContext, completion: @escaping () -> Void) -> ViewController
1426+
func makeGiftAuctionBidScreen(context: AccountContext, toPeerId: EnginePeer.Id, text: String?, entities: [MessageTextEntity]?, hideName: Bool, auctionContext: GiftAuctionContext, acquiredGifts: [GiftAuctionAcquiredGift]?) -> ViewController
1427+
func makeGiftAuctionViewScreen(context: AccountContext, auctionContext: GiftAuctionContext, completion: @escaping ([GiftAuctionAcquiredGift]?) -> Void) -> ViewController
14281428
func makeGiftAuctionActiveBidsScreen(context: AccountContext) -> ViewController
14291429

14301430
func makeStorySharingScreen(context: AccountContext, subject: StorySharingSubject, parentController: ViewController) -> ViewController

submodules/TelegramBaseController/Sources/TelegramBaseController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder {
565565
guard let self, let auction else {
566566
return
567567
}
568-
let controller = self.context.sharedContext.makeGiftAuctionBidScreen(context: self.context, toPeerId: auction.currentBidPeerId ?? self.context.account.peerId, text: nil, entities: nil, hideName: false, auctionContext: auction)
568+
let controller = self.context.sharedContext.makeGiftAuctionBidScreen(context: self.context, toPeerId: auction.currentBidPeerId ?? self.context.account.peerId, text: nil, entities: nil, hideName: false, auctionContext: auction, acquiredGifts: nil)
569569
self.push(controller)
570570
})
571571
}

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public final class GiftAuctionContext {
6060
}
6161

6262
public struct MyState: Equatable {
63-
public var isOutbid: Bool
63+
public var isReturned: Bool
6464
public var bidAmount: Int64?
6565
public var bidDate: Int32?
6666
public var minBidAmount: Int64?
@@ -78,7 +78,11 @@ public final class GiftAuctionContext {
7878
public let gift: StarGift
7979

8080
public var isActive: Bool {
81-
return myState?.bidAmount != nil
81+
if case .finished = auctionState {
82+
return false
83+
} else {
84+
return myState?.bidAmount != nil
85+
}
8286
}
8387

8488
private let disposable = MetaDisposable()
@@ -132,7 +136,7 @@ public final class GiftAuctionContext {
132136

133137
private var currentVersion: Int32 {
134138
var currentVersion: Int32 = 0
135-
if case let .ongoing(version, _, _, _, _, _, _, _, _, _) = self.auctionState {
139+
if case let .ongoing(version, _, _, _, _, _, _, _, _, _) = self.auctionState {
136140
currentVersion = version
137141
}
138142
return currentVersion
@@ -180,7 +184,10 @@ public final class GiftAuctionContext {
180184
}
181185

182186
func updateAuctionState(_ auctionState: GiftAuctionContext.State.AuctionState) {
183-
self.auctionState = auctionState
187+
if case let .ongoing(version, _, _, _, _, _, _, _, _, _) = auctionState, version < self.currentVersion {
188+
} else {
189+
self.auctionState = auctionState
190+
}
184191
self.pushState()
185192
}
186193

@@ -255,7 +262,7 @@ extension GiftAuctionContext.State.MyState {
255262
init(apiAuctionUserState: Api.StarGiftAuctionUserState) {
256263
switch apiAuctionUserState {
257264
case let .starGiftAuctionUserState(flags, bidAmount, bidDate, minBidAmount, bidPeerId, acquiredCount):
258-
self.isOutbid = (flags & (1 << 1)) != 0
265+
self.isReturned = (flags & (1 << 1)) != 0
259266
self.bidAmount = bidAmount
260267
self.bidDate = bidDate
261268
self.minBidAmount = minBidAmount

submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ final class GiftOptionsScreenComponent: Component {
383383
text: nil,
384384
entities: nil,
385385
hideName: false,
386-
auctionContext: auctionContext
386+
auctionContext: auctionContext,
387+
acquiredGifts: nil
387388
)
388389
mainController.push(giftController)
389390
} else {
@@ -415,11 +416,12 @@ final class GiftOptionsScreenComponent: Component {
415416
let giftController = component.context.sharedContext.makeGiftAuctionViewScreen(
416417
context: component.context,
417418
auctionContext: auctionContext,
418-
completion: { [weak mainController] in
419+
completion: { [weak mainController] acquiredGifts in
419420
let controller = GiftSetupScreen(
420421
context: context,
421422
peerId: component.peerId,
422423
subject: .starGift(gift, nil),
424+
auctionAcquiredGifts: acquiredGifts,
423425
completion: nil
424426
)
425427
mainController?.push(controller)

submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,20 @@ private final class GiftSetupScreenComponent: Component {
4646
let context: AccountContext
4747
let peerId: EnginePeer.Id
4848
let subject: GiftSetupScreen.Subject
49+
let auctionAcquiredGifts: [GiftAuctionAcquiredGift]?
4950
let completion: (() -> Void)?
5051

5152
init(
5253
context: AccountContext,
5354
peerId: EnginePeer.Id,
5455
subject: GiftSetupScreen.Subject,
56+
auctionAcquiredGifts: [GiftAuctionAcquiredGift]?,
5557
completion: (() -> Void)? = nil
5658
) {
5759
self.context = context
5860
self.peerId = peerId
5961
self.subject = subject
62+
self.auctionAcquiredGifts = auctionAcquiredGifts
6063
self.completion = completion
6164
}
6265

@@ -479,7 +482,8 @@ private final class GiftSetupScreenComponent: Component {
479482
text: textInputText.string,
480483
entities: entities,
481484
hideName: self.hideName,
482-
auctionContext: auctionContext
485+
auctionContext: auctionContext,
486+
acquiredGifts: component.auctionAcquiredGifts
483487
)
484488
environment.controller()?.dismiss()
485489
navigationController.pushViewController(controller)
@@ -2020,6 +2024,7 @@ public class GiftSetupScreen: ViewControllerComponentContainer {
20202024
context: AccountContext,
20212025
peerId: EnginePeer.Id,
20222026
subject: Subject,
2027+
auctionAcquiredGifts: [GiftAuctionAcquiredGift]? = nil,
20232028
completion: (() -> Void)? = nil
20242029
) {
20252030
self.context = context
@@ -2028,6 +2033,7 @@ public class GiftSetupScreen: ViewControllerComponentContainer {
20282033
context: context,
20292034
peerId: peerId,
20302035
subject: subject,
2036+
auctionAcquiredGifts: auctionAcquiredGifts,
20312037
completion: completion
20322038
), navigationBarAppearance: .none, theme: .default)
20332039

submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionActiveBidsScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ private final class GiftAuctionActiveBidsScreenComponent: Component {
331331
guard let self, let component = self.component, let auction, let controller = environment.controller(), let navigationController = controller.navigationController as? NavigationController else {
332332
return
333333
}
334-
let bidController = component.context.sharedContext.makeGiftAuctionBidScreen(context: component.context, toPeerId: auction.currentBidPeerId ?? component.context.account.peerId, text: nil, entities: nil, hideName: false, auctionContext: auction)
334+
let bidController = component.context.sharedContext.makeGiftAuctionBidScreen(context: component.context, toPeerId: auction.currentBidPeerId ?? component.context.account.peerId, text: nil, entities: nil, hideName: false, auctionContext: auction, acquiredGifts: nil)
335335
navigationController.pushViewController(bidController)
336336
})
337337
}

0 commit comments

Comments
 (0)