Fixed sort of received star gifts.

This commit is contained in:
23rd 2025-03-20 10:35:15 +03:00
parent fe0c1acd79
commit 0d346610a2
3 changed files with 4 additions and 13 deletions

View file

@ -816,6 +816,7 @@ std::optional<Data::StarGift> FromTL(
.lastSaleDate = data.vlast_sale_date().value_or_empty(),
.upgradable = data.vupgrade_stars().has_value(),
.birthday = data.is_birthday(),
.soldOut = data.is_sold_out(),
});
}, [&](const MTPDstarGiftUnique &data) {
const auto total = data.vavailability_total().v;

View file

@ -718,19 +718,8 @@ void PreviewWrap::paintEvent(QPaintEvent *e) {
for (auto &gift : gifts) {
list.push_back({ .info = gift });
}
ranges::sort(list, [](
const GiftTypeStars &a,
const GiftTypeStars &b) {
if (!a.info.limitedCount && !b.info.limitedCount) {
return a.info.stars <= b.info.stars;
} else if (!a.info.limitedCount) {
return true;
} else if (!b.info.limitedCount) {
return false;
} else if (a.info.limitedLeft != b.info.limitedLeft) {
return a.info.limitedLeft > b.info.limitedLeft;
}
return a.info.stars <= b.info.stars;
ranges::stable_sort(list, [](const auto &a, const auto &b) {
return a.info.soldOut < b.info.soldOut;
});
auto &map = Map[session];

View file

@ -69,6 +69,7 @@ struct StarGift {
TimeId lastSaleDate = 0;
bool upgradable = false;
bool birthday = false;
bool soldOut = false;
friend inline bool operator==(
const StarGift &,