Skip to content

Commit d574fb7

Browse files
committed
Various fixes
1 parent 62157e9 commit d574fb7

File tree

5 files changed

+40
-36
lines changed

5 files changed

+40
-36
lines changed

submodules/MediaPickerUI/Sources/MediaPickerScreen.swift

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
205205
private let titleView: MediaPickerTitleView
206206
private let cancelButtonNode: WebAppCancelButtonNode
207207

208-
private var glassContainerView = GlassBackgroundContainerView()
209208
private var cancelButton: ComponentView<Empty>?
210209
private var rightButton: ComponentView<Empty>?
211210
private let moreButtonPlayOnce = ActionSlot<Void>()
@@ -2573,14 +2572,6 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
25732572
transition.updateAlpha(layer: self.controllerNode.topEdgeEffectView.layer, alpha: self.controllerNode.scrolledExactlyToTop && self.controllerNode.currentDisplayMode == .all ? 0.0 : 1.0)
25742573
self.controllerNode.topEdgeEffectView.update(content: topEdgeColor, blur: true, alpha: 0.8, rect: topEdgeEffectFrame, edge: .top, edgeSize: topEdgeEffectFrame.height, transition: ComponentTransition(transition))
25752574

2576-
if self.cancelButton != nil {
2577-
if self.glassContainerView.superview == nil {
2578-
self.view.addSubview(self.glassContainerView)
2579-
}
2580-
self.glassContainerView.frame = CGRect(origin: .zero, size: CGSize(width: layout.size.width, height: 72.0))
2581-
self.glassContainerView.update(size: self.glassContainerView.frame.size, isDark: self.presentationData.theme.overallDarkAppearance, transition: .immediate)
2582-
}
2583-
25842575
if let cancelButton = self.cancelButton {
25852576
if cancelButton.view == nil {
25862577
buttonTransition = .immediate
@@ -2608,7 +2599,7 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
26082599
let cancelButtonFrame = CGRect(origin: CGPoint(x: barButtonSideInset + layout.safeInsets.left, y: barButtonSideInset), size: cancelButtonSize)
26092600
if let view = cancelButton.view {
26102601
if view.superview == nil {
2611-
self.glassContainerView.contentView.addSubview(view)
2602+
self.view.addSubview(view)
26122603
}
26132604
view.bounds = CGRect(origin: .zero, size: cancelButtonFrame.size)
26142605
view.center = cancelButtonFrame.center
@@ -2643,7 +2634,7 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
26432634
let moreButtonFrame = CGRect(origin: CGPoint(x: layout.size.width - moreButtonSize.width - barButtonSideInset - layout.safeInsets.right, y: barButtonSideInset), size: moreButtonSize)
26442635
if let view = moreButton.view {
26452636
if view.superview == nil {
2646-
self.glassContainerView.contentView.addSubview(view)
2637+
self.view.addSubview(view)
26472638
}
26482639
view.bounds = CGRect(origin: .zero, size: moreButtonFrame.size)
26492640
view.center = moreButtonFrame.center

submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1901,7 +1901,7 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
19011901
case let .updateMonoForumNoPaidException(flags, channelId, savedPeerId):
19021902
updatedState.updateMonoForumNoPaidException(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId: savedPeerId.peerId.toInt64(), isFree: (flags & (1 << 0)) != 0)
19031903
case let .updateStarGiftAuctionState(giftId, state):
1904-
if let state = GiftAuctionContext.State.AuctionState(apiAuctionState: state) {
1904+
if let state = GiftAuctionContext.State.AuctionState(apiAuctionState: state, peers: updatedState.peers) {
19051905
updatedState.updateStarGiftAuctionState(giftId: giftId, state: state)
19061906
}
19071907
case let .updateStarGiftAuctionUserState(giftId, userState):

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

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private func _internal_getStarGiftAuctionState(postbox: Postbox, network: Networ
3737
}
3838
return (
3939
gift: gift,
40-
state: GiftAuctionContext.State.AuctionState(apiAuctionState: state),
40+
state: GiftAuctionContext.State.AuctionState(apiAuctionState: state, transaction: transaction),
4141
myState: GiftAuctionContext.State.MyState(apiAuctionUserState: userState),
4242
timeout: timeout
4343
)
@@ -55,7 +55,7 @@ public final class GiftAuctionContext {
5555
}
5656

5757
public enum AuctionState: Equatable {
58-
case ongoing(version: Int32, startDate: Int32, endDate: Int32, minBidAmount: Int64, bidLevels: [BidLevel], topBidders: [EnginePeer.Id], nextRoundDate: Int32, giftsLeft: Int32, currentRound: Int32, totalRounds: Int32)
58+
case ongoing(version: Int32, startDate: Int32, endDate: Int32, minBidAmount: Int64, bidLevels: [BidLevel], topBidders: [EnginePeer], nextRoundDate: Int32, giftsLeft: Int32, currentRound: Int32, totalRounds: Int32)
5959
case finished(startDate: Int32, endDate: Int32, averagePrice: Int64)
6060
}
6161

@@ -208,10 +208,33 @@ extension GiftAuctionContext.State.BidLevel {
208208
}
209209

210210
extension GiftAuctionContext.State.AuctionState {
211-
init?(apiAuctionState: Api.StarGiftAuctionState) {
211+
init?(apiAuctionState: Api.StarGiftAuctionState, peers: [PeerId: Peer]) {
212212
switch apiAuctionState {
213-
case let .starGiftAuctionState(version, startDate, endDate, minBidAmount, bidLevels, topBidders, nextRoundAt, giftsLeft, currentRound, totalRounds):
214-
self = .ongoing(version: version, startDate: startDate, endDate: endDate, minBidAmount: minBidAmount, bidLevels: bidLevels.map(GiftAuctionContext.State.BidLevel.init(apiBidLevel:)), topBidders: topBidders.map { EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) }, nextRoundDate: nextRoundAt, giftsLeft: giftsLeft, currentRound: currentRound, totalRounds: totalRounds)
213+
case let .starGiftAuctionState(version, startDate, endDate, minBidAmount, bidLevels, topBiddersPeerIds, nextRoundAt, giftsLeft, currentRound, totalRounds):
214+
var topBidders: [EnginePeer] = []
215+
for peerId in topBiddersPeerIds {
216+
if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(peerId))] {
217+
topBidders.append(EnginePeer(peer))
218+
}
219+
}
220+
self = .ongoing(version: version, startDate: startDate, endDate: endDate, minBidAmount: minBidAmount, bidLevels: bidLevels.map(GiftAuctionContext.State.BidLevel.init(apiBidLevel:)), topBidders: topBidders, nextRoundDate: nextRoundAt, giftsLeft: giftsLeft, currentRound: currentRound, totalRounds: totalRounds)
221+
case let .starGiftAuctionStateFinished(startDate, endDate, averagePrice):
222+
self = .finished(startDate: startDate, endDate: endDate, averagePrice: averagePrice)
223+
case .starGiftAuctionStateNotModified:
224+
return nil
225+
}
226+
}
227+
228+
init?(apiAuctionState: Api.StarGiftAuctionState, transaction: Transaction) {
229+
switch apiAuctionState {
230+
case let .starGiftAuctionState(version, startDate, endDate, minBidAmount, bidLevels, topBiddersPeerIds, nextRoundAt, giftsLeft, currentRound, totalRounds):
231+
var topBidders: [EnginePeer] = []
232+
for peerId in topBiddersPeerIds {
233+
if let peer = transaction.getPeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(peerId))) {
234+
topBidders.append(EnginePeer(peer))
235+
}
236+
}
237+
self = .ongoing(version: version, startDate: startDate, endDate: endDate, minBidAmount: minBidAmount, bidLevels: bidLevels.map(GiftAuctionContext.State.BidLevel.init(apiBidLevel:)), topBidders: topBidders, nextRoundDate: nextRoundAt, giftsLeft: giftsLeft, currentRound: currentRound, totalRounds: totalRounds)
215238
case let .starGiftAuctionStateFinished(startDate, endDate, averagePrice):
216239
self = .finished(startDate: startDate, endDate: endDate, averagePrice: averagePrice)
217240
case .starGiftAuctionStateNotModified:
@@ -314,7 +337,7 @@ func _internal_getActiveGiftAuctions(account: Account, hash: Int64) -> Signal<[G
314337
auctionContexts.append(GiftAuctionContext(
315338
account: account,
316339
gift: gift,
317-
initialAuctionState: GiftAuctionContext.State.AuctionState(apiAuctionState: auctionState),
340+
initialAuctionState: GiftAuctionContext.State.AuctionState(apiAuctionState: auctionState, transaction: transaction),
318341
initialMyState: GiftAuctionContext.State.MyState(apiAuctionUserState: userState),
319342
initialTimeout: nil
320343
))

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,14 +1793,6 @@ private final class GiftAuctionBidScreenComponent: Component {
17931793
self.giftAuctionState = state
17941794

17951795
var peerIds: [EnginePeer.Id] = []
1796-
if case let .ongoing(_, _, _, _, _, topBidders, _, _, _, _) = state?.auctionState {
1797-
for bidder in topBidders {
1798-
if self.peersMap[bidder] == nil {
1799-
peerIds.append(bidder)
1800-
}
1801-
}
1802-
}
1803-
18041796
var transition = ComponentTransition.spring(duration: 0.4)
18051797

18061798
if isFirstTime {
@@ -2357,17 +2349,15 @@ private final class GiftAuctionBidScreenComponent: Component {
23572349
}
23582350

23592351
var i: Int32 = 1
2360-
for bidder in topBidders {
2361-
if let peer = self.peersMap[bidder] {
2362-
var bid: Int64 = 0
2363-
for level in bidLevels {
2364-
if level.position == i {
2365-
bid = level.amount
2366-
break
2367-
}
2352+
for peer in topBidders {
2353+
var bid: Int64 = 0
2354+
for level in bidLevels {
2355+
if level.position == i {
2356+
bid = level.amount
2357+
break
23682358
}
2369-
topBidsComponents.append((bidder, AnyComponent(PeerComponent(context: component.context, theme: environment.theme, groupingSeparator: environment.dateTimeFormat.groupingSeparator, peer: peer, place: i, amount: bid, isLast: i == topBidders.count, action: peer.id != component.context.account.peerId ? { [weak self] in self?.openPeer(peer, dismiss: false) } : nil))))
23702359
}
2360+
topBidsComponents.append((peer.id, AnyComponent(PeerComponent(context: component.context, theme: environment.theme, groupingSeparator: environment.dateTimeFormat.groupingSeparator, peer: peer, place: i, amount: bid, isLast: i == topBidders.count, action: peer.id != component.context.account.peerId ? { [weak self] in self?.openPeer(peer, dismiss: false) } : nil))))
23712361
i += 1
23722362
}
23732363

submodules/TelegramUI/Components/GlassBarButtonComponent/Sources/GlassBarButtonComponent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public final class GlassBarButtonComponent: Component {
193193
transition.setAlpha(view: self.genericContainerView, alpha: genericAlpha)
194194
transition.setFrame(view: self.genericContainerView, frame: bounds)
195195

196-
transition.setAlpha(view: self.glassContainerView, alpha: glassAlpha)
196+
transition.setAlpha(view: self.glassBackgroundView, alpha: glassAlpha)
197197
transition.setFrame(view: self.glassContainerView, frame: bounds)
198198

199199
transition.setFrame(view: self.genericBackgroundView, frame: bounds)

0 commit comments

Comments
 (0)