Skip to content

Commit b0726cd

Browse files
committed
Don't show lock on sold out gifts.
1 parent 64f5fa8 commit b0726cd

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

Telegram/SourceFiles/boxes/star_gift_box.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,6 +2439,30 @@ void SendGiftBox(
24392439
const auto premiumNeeded = star && star->info.requirePremium;
24402440
if (premiumNeeded && !peer->session().premium()) {
24412441
Settings::ShowPremiumGiftPremium(window, star->info);
2442+
} else if (unique && star->resale) {
2443+
window->show(Box(
2444+
Settings::GlobalStarGiftBox,
2445+
window->uiShow(),
2446+
star->info,
2447+
Settings::StarGiftResaleInfo{
2448+
.recipientId = peer->id,
2449+
.forceTon = star->forceTon,
2450+
},
2451+
Settings::CreditsEntryBoxStyleOverrides()));
2452+
} else if (star && star->resale) {
2453+
const auto id = star->info.id;
2454+
if (state->resaleRequestingId == id) {
2455+
return;
2456+
}
2457+
state->resaleRequestingId = id;
2458+
state->resaleLifetime = ShowStarGiftResale(
2459+
window,
2460+
peer,
2461+
id,
2462+
star->info.resellTitle,
2463+
[=] { state->resaleRequestingId = 0; });
2464+
} else if (star && IsSoldOut(star->info)) {
2465+
window->show(Box(SoldOutBox, window, *star));
24422466
} else if (star
24432467
&& star->info.lockedUntilDate
24442468
&& star->info.lockedUntilDate > base::unixtime::now()) {
@@ -2495,30 +2519,6 @@ void SendGiftBox(
24952519
Api::InputSavedStarGiftId(savedId, unique),
24962520
peer->input),
24972521
formReady);
2498-
} else if (unique && star->resale) {
2499-
window->show(Box(
2500-
Settings::GlobalStarGiftBox,
2501-
window->uiShow(),
2502-
star->info,
2503-
Settings::StarGiftResaleInfo{
2504-
.recipientId = peer->id,
2505-
.forceTon = star->forceTon,
2506-
},
2507-
Settings::CreditsEntryBoxStyleOverrides()));
2508-
} else if (star && star->resale) {
2509-
const auto id = star->info.id;
2510-
if (state->resaleRequestingId == id) {
2511-
return;
2512-
}
2513-
state->resaleRequestingId = id;
2514-
state->resaleLifetime = ShowStarGiftResale(
2515-
window,
2516-
peer,
2517-
id,
2518-
star->info.resellTitle,
2519-
[=] { state->resaleRequestingId = 0; });
2520-
} else if (star && IsSoldOut(star->info)) {
2521-
window->show(Box(SoldOutBox, window, *star));
25222522
} else if (star
25232523
&& star->info.perUserTotal
25242524
&& !star->info.perUserRemains) {

Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ void GiftButton::setDescriptor(const GiftDescriptor &descriptor, Mode mode) {
298298
_stars->setColorOverride(
299299
Ui::Premium::CreditsIconGradientStops());
300300
}
301-
_lockedUntilDate = data.info.lockedUntilDate;
301+
_lockedUntilDate = data.resale ? 0 : data.info.lockedUntilDate;
302302
});
303303

304304
refreshLocked();
@@ -632,16 +632,20 @@ void GiftButton::cacheUniqueBackground(
632632

633633
void GiftButton::paintEvent(QPaintEvent *e) {
634634
auto p = QPainter(this);
635-
const auto unique = v::is<GiftTypeStars>(_descriptor)
636-
? v::get<GiftTypeStars>(_descriptor).info.unique.get()
637-
: nullptr;
635+
const auto stargift = std::get_if<GiftTypeStars>(&_descriptor);
636+
const auto unique = stargift ? stargift->info.unique.get() : nullptr;
638637
const auto onsale = unique && unique->starsForResale && small();
639-
const auto requirePremium = v::is<GiftTypeStars>(_descriptor)
640-
&& !v::get<GiftTypeStars>(_descriptor).userpic
641-
&& !v::get<GiftTypeStars>(_descriptor).info.unique
642-
&& v::get<GiftTypeStars>(_descriptor).info.requirePremium;
643-
const auto hidden = v::is<GiftTypeStars>(_descriptor)
644-
&& v::get<GiftTypeStars>(_descriptor).hidden;
638+
const auto requirePremium = stargift
639+
&& !stargift->userpic
640+
&& !stargift->info.unique
641+
&& stargift->info.requirePremium;
642+
const auto hidden = stargift && stargift->hidden;
643+
const auto soldOut = stargift
644+
&& !(stargift->pinned || stargift->pinnedSelection)
645+
&& !unique
646+
&& !stargift->userpic
647+
&& stargift->info.limitedCount
648+
&& !stargift->info.limitedLeft;
645649
const auto extend = currentExtend();
646650
const auto position = QPoint(extend.left(), extend.top());
647651
const auto background = _delegate->background();
@@ -683,7 +687,7 @@ void GiftButton::paintEvent(QPaintEvent *e) {
683687
progress * (thickness * 2 + st::giftBoxUserpicSkip)));
684688
}
685689
}
686-
if (_locked) {
690+
if (_locked && !soldOut) {
687691
st::giftBoxLockIcon.paint(
688692
p,
689693
position + st::giftBoxLockIconPosition,
@@ -780,10 +784,6 @@ void GiftButton::paintEvent(QPaintEvent *e) {
780784
const auto count = data.info.limitedCount;
781785
const auto pinned = data.pinned || data.pinnedSelection;
782786
if (count || pinned) {
783-
const auto soldOut = !pinned
784-
&& !unique
785-
&& !data.userpic
786-
&& !data.info.limitedLeft;
787787
const auto yourLeft = data.info.perUserTotal
788788
? (data.info.perUserRemains
789789
? tr::lng_gift_stars_your_left(

0 commit comments

Comments
 (0)