Skip to content

Commit 8f33585

Browse files
committed
Various improvements
1 parent c813a76 commit 8f33585

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

Telegram/Telegram-iOS/en.lproj/Localizable.strings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15226,8 +15226,10 @@ Error: %8$@";
1522615226
"Gift.AuctionBid.AddMoreStars" = "Add at least %@ to increase your bid.";
1522715227
"Gift.AuctionBid.AddMoreStars.Stars_1" = "%@ Star";
1522815228
"Gift.AuctionBid.AddMoreStars.Stars_any" = "%@ Stars";
15229+
"Gift.AuctionBid.AddMoreStars.Set" = "Set";
1522915230
"Gift.AuctionBid.Top" = "TOP %@";
1523015231
"Gift.AuctionBid.Custom" = "Custom";
15232+
"Gift.AuctionBid.MinimumBidIncreased" = "The minimum bid increased to **%@**.";
1523115233

1523215234
"Gift.AuctionBid.CustomBid.Title" = "Place a Custom Bid";
1523315235
"Gift.AuctionBid.CustomBid.Text" = "If you fall below the top %@, your bid will roll over to the next drop.";

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ final class GiftOptionsScreenComponent: Component {
353353
return
354354
}
355355

356-
if let perUserLimit = gift.perUserLimit, perUserLimit.remains == 0 {
356+
if let perUserLimit = gift.perUserLimit, perUserLimit.remains == 0 && (gift.availability?.resale ?? 0) == 0 {
357357
let text = environment.strings.Gift_Options_Gift_BuyLimitReached(perUserLimit.total)
358358
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
359359
let controller = UndoOverlayController(presentationData: presentationData, content: .sticker(context: component.context, file: gift.file, loop: true, title: nil, text: text, undoText: nil, customAction: nil), action: { _ in return false })
@@ -447,7 +447,7 @@ final class GiftOptionsScreenComponent: Component {
447447
}
448448
}))
449449
} else {
450-
if let availability = gift.availability, availability.remains == 0 {
450+
if let availability = gift.availability, availability.remains == 0 || gift.perUserLimit?.remains == 0 || component.peerId.namespace == Namespaces.Peer.CloudChannel {
451451
if availability.resale > 0 {
452452
let storeController = component.context.sharedContext.makeGiftStoreController(
453453
context: component.context,
@@ -611,7 +611,7 @@ final class GiftOptionsScreenComponent: Component {
611611
text = environment.strings.Gift_Options_Gift_Auction
612612
ribbonColor = .orange
613613
outline = .orange
614-
} else if let perUserLimit = gift.perUserLimit {
614+
} else if let perUserLimit = gift.perUserLimit, component.peerId.namespace != Namespaces.Peer.CloudChannel {
615615
text = environment.strings.Gift_Options_Gift_Limited_Left(perUserLimit.remains)
616616
} else {
617617
text = environment.strings.Gift_Options_Gift_Limited
@@ -1831,7 +1831,7 @@ final class GiftOptionsScreenComponent: Component {
18311831
var filteredStarGifts = starGifts
18321832
if peerId.namespace == Namespaces.Peer.CloudChannel {
18331833
filteredStarGifts = filteredStarGifts?.filter { gift in
1834-
if case let .generic(gift) = gift, gift.availability != nil {
1834+
if case let .generic(gift) = gift, let availability = gift.availability, availability.resale == 0 {
18351835
return false
18361836
}
18371837
return true

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

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,10 +1528,15 @@ private final class GiftAuctionBidScreenComponent: Component {
15281528
title: nil,
15291529
text: presentationData.strings.Gift_AuctionBid_AddMoreStars(presentationData.strings.Gift_AuctionBid_AddMoreStars_Stars(Int32(clamping: myMinBidAmount - myBidAmount))).string,
15301530
timeout: nil,
1531-
customUndoText: nil
1531+
customUndoText: presentationData.strings.Gift_AuctionBid_AddMoreStars_Set
15321532
),
15331533
position: .bottom,
1534-
action: { _ in return true }
1534+
action: { [weak self] action in
1535+
if let self, case .undo = action {
1536+
self.resetSliderValue(component: self.component, forceMinimum: true)
1537+
}
1538+
return true
1539+
}
15351540
),
15361541
in: .current
15371542
)
@@ -1613,8 +1618,28 @@ private final class GiftAuctionBidScreenComponent: Component {
16131618
return
16141619
}
16151620

1621+
HapticFeedback().error()
1622+
1623+
let currentValue = self.amount.realValue
16161624
self.component?.context.starsContext?.load(force: true)
1617-
self.resetSliderValue()
1625+
self.resetSliderValue(component: self.component, forceMinimum: true)
1626+
1627+
if self.amount.realValue > currentValue {
1628+
controller.present(
1629+
UndoOverlayController(
1630+
presentationData: presentationData,
1631+
content: .info(
1632+
title: nil,
1633+
text: presentationData.strings.Gift_AuctionBid_MinimumBidIncreased(presentationData.strings.Gift_AuctionBid_AddMoreStars_Stars(Int32(clamping: self.amount.realValue))).string,
1634+
timeout: nil,
1635+
customUndoText: nil
1636+
),
1637+
position: .bottom,
1638+
action: { _ in return true }
1639+
),
1640+
in: .current
1641+
)
1642+
}
16181643

16191644
Queue.mainQueue().after(0.1) {
16201645
self.isLoading = false
@@ -1826,7 +1851,7 @@ private final class GiftAuctionBidScreenComponent: Component {
18261851
self.environment?.controller()?.present(controller, in: .window(.root))
18271852
}
18281853

1829-
func resetSliderValue(component: GiftAuctionBidScreenComponent? = nil) {
1854+
func resetSliderValue(component: GiftAuctionBidScreenComponent? = nil, forceMinimum: Bool = false) {
18301855
guard let state = self.giftAuctionState else {
18311856
return
18321857
}
@@ -1839,16 +1864,13 @@ private final class GiftAuctionBidScreenComponent: Component {
18391864
}
18401865
}
18411866
var currentValue = max(Int(minBidAmount), 100)
1867+
var minAllowedRealValue: Int64 = minBidAmount
18421868
if let myBidAmount = state.myState.bidAmount {
1843-
if let component, let bidPeerId = state.myState.bidPeerId, bidPeerId != component.toPeerId, let myMinBidAmount = state.myState.minBidAmount {
1869+
if let component, let bidPeerId = state.myState.bidPeerId, bidPeerId != component.toPeerId || forceMinimum, let myMinBidAmount = state.myState.minBidAmount {
18441870
currentValue = Int(myMinBidAmount)
18451871
} else {
18461872
currentValue = Int(myBidAmount)
18471873
}
1848-
}
1849-
1850-
var minAllowedRealValue: Int64 = minBidAmount
1851-
if let myBidAmount = state.myState.bidAmount {
18521874
minAllowedRealValue = myBidAmount
18531875
}
18541876

0 commit comments

Comments
 (0)