Skip to content

Commit

Permalink
Improved sort of received star gifts.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd committed Jan 25, 2025
1 parent 321490e commit 28a79bf
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Telegram/SourceFiles/boxes/star_gift_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,21 @@ 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;
});

auto &map = Map[session];
if (map.last != list) {
map.last = list;
Expand Down

0 comments on commit 28a79bf

Please sign in to comment.