mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 07:33:52 +02:00
Fixed sort of received star gifts.
This commit is contained in:
parent
fe0c1acd79
commit
0d346610a2
3 changed files with 4 additions and 13 deletions
|
@ -816,6 +816,7 @@ std::optional<Data::StarGift> FromTL(
|
||||||
.lastSaleDate = data.vlast_sale_date().value_or_empty(),
|
.lastSaleDate = data.vlast_sale_date().value_or_empty(),
|
||||||
.upgradable = data.vupgrade_stars().has_value(),
|
.upgradable = data.vupgrade_stars().has_value(),
|
||||||
.birthday = data.is_birthday(),
|
.birthday = data.is_birthday(),
|
||||||
|
.soldOut = data.is_sold_out(),
|
||||||
});
|
});
|
||||||
}, [&](const MTPDstarGiftUnique &data) {
|
}, [&](const MTPDstarGiftUnique &data) {
|
||||||
const auto total = data.vavailability_total().v;
|
const auto total = data.vavailability_total().v;
|
||||||
|
|
|
@ -718,19 +718,8 @@ void PreviewWrap::paintEvent(QPaintEvent *e) {
|
||||||
for (auto &gift : gifts) {
|
for (auto &gift : gifts) {
|
||||||
list.push_back({ .info = gift });
|
list.push_back({ .info = gift });
|
||||||
}
|
}
|
||||||
ranges::sort(list, [](
|
ranges::stable_sort(list, [](const auto &a, const auto &b) {
|
||||||
const GiftTypeStars &a,
|
return a.info.soldOut < b.info.soldOut;
|
||||||
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;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
auto &map = Map[session];
|
auto &map = Map[session];
|
||||||
|
|
|
@ -69,6 +69,7 @@ struct StarGift {
|
||||||
TimeId lastSaleDate = 0;
|
TimeId lastSaleDate = 0;
|
||||||
bool upgradable = false;
|
bool upgradable = false;
|
||||||
bool birthday = false;
|
bool birthday = false;
|
||||||
|
bool soldOut = false;
|
||||||
|
|
||||||
friend inline bool operator==(
|
friend inline bool operator==(
|
||||||
const StarGift &,
|
const StarGift &,
|
||||||
|
|
Loading…
Add table
Reference in a new issue