mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Show correct presents in Stars gifts.
This commit is contained in:
parent
a5ffd8b7cf
commit
992c876930
3 changed files with 13 additions and 1 deletions
|
@ -22,6 +22,16 @@ GiftBoxPack::GiftBoxPack(not_null<Main::Session*> session)
|
|||
|
||||
GiftBoxPack::~GiftBoxPack() = default;
|
||||
|
||||
int GiftBoxPack::monthsForStars(int stars) const {
|
||||
if (stars <= 1000) {
|
||||
return 3;
|
||||
} else if (stars < 2500) {
|
||||
return 6;
|
||||
} else {
|
||||
return 12;
|
||||
}
|
||||
}
|
||||
|
||||
DocumentData *GiftBoxPack::lookup(int months) const {
|
||||
const auto it = ranges::lower_bound(_localMonths, months);
|
||||
const auto fallback = _documents.empty() ? nullptr : _documents[0];
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
~GiftBoxPack();
|
||||
|
||||
void load();
|
||||
[[nodiscard]] int monthsForStars(int stars) const;
|
||||
[[nodiscard]] DocumentData *lookup(int months) const;
|
||||
[[nodiscard]] Data::FileOrigin origin() const;
|
||||
|
||||
|
|
|
@ -185,8 +185,9 @@ void PremiumGift::ensureStickerCreated() const {
|
|||
return;
|
||||
}
|
||||
const auto &session = _parent->history()->session();
|
||||
const auto months = stars() ? 1 : _data.count;
|
||||
auto &packs = session.giftBoxStickersPacks();
|
||||
const auto count = stars();
|
||||
const auto months = count ? packs.monthsForStars(count) : _data.count;
|
||||
if (const auto document = packs.lookup(months)) {
|
||||
if (const auto sticker = document->sticker()) {
|
||||
const auto skipPremiumEffect = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue