Various fixes

This commit is contained in:
Ilya Laktyushin 2025-11-13 16:10:30 +04:00
parent 62157e92ae
commit d574fb7a11
5 changed files with 40 additions and 36 deletions

View File

@ -205,7 +205,6 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
private let titleView: MediaPickerTitleView
private let cancelButtonNode: WebAppCancelButtonNode
private var glassContainerView = GlassBackgroundContainerView()
private var cancelButton: ComponentView<Empty>?
private var rightButton: ComponentView<Empty>?
private let moreButtonPlayOnce = ActionSlot<Void>()
@ -2573,14 +2572,6 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
transition.updateAlpha(layer: self.controllerNode.topEdgeEffectView.layer, alpha: self.controllerNode.scrolledExactlyToTop && self.controllerNode.currentDisplayMode == .all ? 0.0 : 1.0)
self.controllerNode.topEdgeEffectView.update(content: topEdgeColor, blur: true, alpha: 0.8, rect: topEdgeEffectFrame, edge: .top, edgeSize: topEdgeEffectFrame.height, transition: ComponentTransition(transition))
if self.cancelButton != nil {
if self.glassContainerView.superview == nil {
self.view.addSubview(self.glassContainerView)
}
self.glassContainerView.frame = CGRect(origin: .zero, size: CGSize(width: layout.size.width, height: 72.0))
self.glassContainerView.update(size: self.glassContainerView.frame.size, isDark: self.presentationData.theme.overallDarkAppearance, transition: .immediate)
}
if let cancelButton = self.cancelButton {
if cancelButton.view == nil {
buttonTransition = .immediate
@ -2608,7 +2599,7 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
let cancelButtonFrame = CGRect(origin: CGPoint(x: barButtonSideInset + layout.safeInsets.left, y: barButtonSideInset), size: cancelButtonSize)
if let view = cancelButton.view {
if view.superview == nil {
self.glassContainerView.contentView.addSubview(view)
self.view.addSubview(view)
}
view.bounds = CGRect(origin: .zero, size: cancelButtonFrame.size)
view.center = cancelButtonFrame.center
@ -2643,7 +2634,7 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
let moreButtonFrame = CGRect(origin: CGPoint(x: layout.size.width - moreButtonSize.width - barButtonSideInset - layout.safeInsets.right, y: barButtonSideInset), size: moreButtonSize)
if let view = moreButton.view {
if view.superview == nil {
self.glassContainerView.contentView.addSubview(view)
self.view.addSubview(view)
}
view.bounds = CGRect(origin: .zero, size: moreButtonFrame.size)
view.center = moreButtonFrame.center

View File

@ -1901,7 +1901,7 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
case let .updateMonoForumNoPaidException(flags, channelId, savedPeerId):
updatedState.updateMonoForumNoPaidException(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId: savedPeerId.peerId.toInt64(), isFree: (flags & (1 << 0)) != 0)
case let .updateStarGiftAuctionState(giftId, state):
if let state = GiftAuctionContext.State.AuctionState(apiAuctionState: state) {
if let state = GiftAuctionContext.State.AuctionState(apiAuctionState: state, peers: updatedState.peers) {
updatedState.updateStarGiftAuctionState(giftId: giftId, state: state)
}
case let .updateStarGiftAuctionUserState(giftId, userState):

View File

@ -37,7 +37,7 @@ private func _internal_getStarGiftAuctionState(postbox: Postbox, network: Networ
}
return (
gift: gift,
state: GiftAuctionContext.State.AuctionState(apiAuctionState: state),
state: GiftAuctionContext.State.AuctionState(apiAuctionState: state, transaction: transaction),
myState: GiftAuctionContext.State.MyState(apiAuctionUserState: userState),
timeout: timeout
)
@ -55,7 +55,7 @@ public final class GiftAuctionContext {
}
public enum AuctionState: Equatable {
case ongoing(version: Int32, startDate: Int32, endDate: Int32, minBidAmount: Int64, bidLevels: [BidLevel], topBidders: [EnginePeer.Id], nextRoundDate: Int32, giftsLeft: Int32, currentRound: Int32, totalRounds: Int32)
case ongoing(version: Int32, startDate: Int32, endDate: Int32, minBidAmount: Int64, bidLevels: [BidLevel], topBidders: [EnginePeer], nextRoundDate: Int32, giftsLeft: Int32, currentRound: Int32, totalRounds: Int32)
case finished(startDate: Int32, endDate: Int32, averagePrice: Int64)
}
@ -208,10 +208,33 @@ extension GiftAuctionContext.State.BidLevel {
}
extension GiftAuctionContext.State.AuctionState {
init?(apiAuctionState: Api.StarGiftAuctionState) {
init?(apiAuctionState: Api.StarGiftAuctionState, peers: [PeerId: Peer]) {
switch apiAuctionState {
case let .starGiftAuctionState(version, startDate, endDate, minBidAmount, bidLevels, topBidders, nextRoundAt, giftsLeft, currentRound, totalRounds):
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)
case let .starGiftAuctionState(version, startDate, endDate, minBidAmount, bidLevels, topBiddersPeerIds, nextRoundAt, giftsLeft, currentRound, totalRounds):
var topBidders: [EnginePeer] = []
for peerId in topBiddersPeerIds {
if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(peerId))] {
topBidders.append(EnginePeer(peer))
}
}
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)
case let .starGiftAuctionStateFinished(startDate, endDate, averagePrice):
self = .finished(startDate: startDate, endDate: endDate, averagePrice: averagePrice)
case .starGiftAuctionStateNotModified:
return nil
}
}
init?(apiAuctionState: Api.StarGiftAuctionState, transaction: Transaction) {
switch apiAuctionState {
case let .starGiftAuctionState(version, startDate, endDate, minBidAmount, bidLevels, topBiddersPeerIds, nextRoundAt, giftsLeft, currentRound, totalRounds):
var topBidders: [EnginePeer] = []
for peerId in topBiddersPeerIds {
if let peer = transaction.getPeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(peerId))) {
topBidders.append(EnginePeer(peer))
}
}
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)
case let .starGiftAuctionStateFinished(startDate, endDate, averagePrice):
self = .finished(startDate: startDate, endDate: endDate, averagePrice: averagePrice)
case .starGiftAuctionStateNotModified:
@ -314,7 +337,7 @@ func _internal_getActiveGiftAuctions(account: Account, hash: Int64) -> Signal<[G
auctionContexts.append(GiftAuctionContext(
account: account,
gift: gift,
initialAuctionState: GiftAuctionContext.State.AuctionState(apiAuctionState: auctionState),
initialAuctionState: GiftAuctionContext.State.AuctionState(apiAuctionState: auctionState, transaction: transaction),
initialMyState: GiftAuctionContext.State.MyState(apiAuctionUserState: userState),
initialTimeout: nil
))

View File

@ -1793,14 +1793,6 @@ private final class GiftAuctionBidScreenComponent: Component {
self.giftAuctionState = state
var peerIds: [EnginePeer.Id] = []
if case let .ongoing(_, _, _, _, _, topBidders, _, _, _, _) = state?.auctionState {
for bidder in topBidders {
if self.peersMap[bidder] == nil {
peerIds.append(bidder)
}
}
}
var transition = ComponentTransition.spring(duration: 0.4)
if isFirstTime {
@ -2357,17 +2349,15 @@ private final class GiftAuctionBidScreenComponent: Component {
}
var i: Int32 = 1
for bidder in topBidders {
if let peer = self.peersMap[bidder] {
var bid: Int64 = 0
for level in bidLevels {
if level.position == i {
bid = level.amount
break
}
for peer in topBidders {
var bid: Int64 = 0
for level in bidLevels {
if level.position == i {
bid = level.amount
break
}
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))))
}
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))))
i += 1
}

View File

@ -193,7 +193,7 @@ public final class GlassBarButtonComponent: Component {
transition.setAlpha(view: self.genericContainerView, alpha: genericAlpha)
transition.setFrame(view: self.genericContainerView, frame: bounds)
transition.setAlpha(view: self.glassContainerView, alpha: glassAlpha)
transition.setAlpha(view: self.glassBackgroundView, alpha: glassAlpha)
transition.setFrame(view: self.glassContainerView, frame: bounds)
transition.setFrame(view: self.genericBackgroundView, frame: bounds)