mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Add "Resale" tab in gift selection.
This commit is contained in:
parent
c726bef740
commit
08fdc4f1fc
2 changed files with 18 additions and 2 deletions
|
@ -3426,6 +3426,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_gift_stars_tabs_my" = "My Gifts";
|
"lng_gift_stars_tabs_my" = "My Gifts";
|
||||||
"lng_gift_stars_tabs_limited" = "Limited";
|
"lng_gift_stars_tabs_limited" = "Limited";
|
||||||
"lng_gift_stars_tabs_in_stock" = "In Stock";
|
"lng_gift_stars_tabs_in_stock" = "In Stock";
|
||||||
|
"lng_gift_stars_tabs_resale" = "Resale";
|
||||||
"lng_gift_send_title" = "Send a Gift";
|
"lng_gift_send_title" = "Send a Gift";
|
||||||
"lng_gift_send_message" = "Enter Message";
|
"lng_gift_send_message" = "Enter Message";
|
||||||
"lng_gift_send_anonymous" = "Hide My Name";
|
"lng_gift_send_anonymous" = "Hide My Name";
|
||||||
|
|
|
@ -109,8 +109,9 @@ namespace {
|
||||||
|
|
||||||
constexpr auto kPriceTabAll = 0;
|
constexpr auto kPriceTabAll = 0;
|
||||||
constexpr auto kPriceTabInStock = -1;
|
constexpr auto kPriceTabInStock = -1;
|
||||||
constexpr auto kPriceTabLimited = -2;
|
constexpr auto kPriceTabResale = -2;
|
||||||
constexpr auto kPriceTabMy = -3;
|
constexpr auto kPriceTabLimited = -3;
|
||||||
|
constexpr auto kPriceTabMy = -4;
|
||||||
constexpr auto kMyGiftsPerPage = 50;
|
constexpr auto kMyGiftsPerPage = 50;
|
||||||
constexpr auto kGiftMessageLimit = 255;
|
constexpr auto kGiftMessageLimit = 255;
|
||||||
constexpr auto kSentToastDuration = 3 * crl::time(1000);
|
constexpr auto kSentToastDuration = 3 * crl::time(1000);
|
||||||
|
@ -1048,6 +1049,8 @@ void PreviewWrap::paintEvent(QPaintEvent *e) {
|
||||||
return simple(tr::lng_gift_stars_tabs_limited(tr::now));
|
return simple(tr::lng_gift_stars_tabs_limited(tr::now));
|
||||||
} else if (price == kPriceTabInStock) {
|
} else if (price == kPriceTabInStock) {
|
||||||
return simple(tr::lng_gift_stars_tabs_in_stock(tr::now));
|
return simple(tr::lng_gift_stars_tabs_in_stock(tr::now));
|
||||||
|
} else if (price == kPriceTabResale) {
|
||||||
|
return simple(tr::lng_gift_stars_tabs_resale(tr::now));
|
||||||
}
|
}
|
||||||
auto &manager = session->data().customEmojiManager();
|
auto &manager = session->data().customEmojiManager();
|
||||||
auto result = Text::String();
|
auto result = Text::String();
|
||||||
|
@ -1511,12 +1514,19 @@ struct GiftPriceTabs {
|
||||||
auto hasSoldOut = false;
|
auto hasSoldOut = false;
|
||||||
auto hasLimited = false;
|
auto hasLimited = false;
|
||||||
auto hasNonLimited = false;
|
auto hasNonLimited = false;
|
||||||
|
auto hasResale = false;
|
||||||
|
auto hasNonResale = false;
|
||||||
for (const auto &gift : gifts) {
|
for (const auto &gift : gifts) {
|
||||||
if (IsSoldOut(gift.info)) {
|
if (IsSoldOut(gift.info)) {
|
||||||
hasSoldOut = true;
|
hasSoldOut = true;
|
||||||
} else {
|
} else {
|
||||||
hasNonSoldOut = true;
|
hasNonSoldOut = true;
|
||||||
}
|
}
|
||||||
|
if (gift.info.starsResellMin) {
|
||||||
|
hasResale = true;
|
||||||
|
} else {
|
||||||
|
hasNonResale = true;
|
||||||
|
}
|
||||||
if (gift.info.limitedCount) {
|
if (gift.info.limitedCount) {
|
||||||
hasLimited = true;
|
hasLimited = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1535,6 +1545,9 @@ struct GiftPriceTabs {
|
||||||
if (hasLimited && hasNonLimited) {
|
if (hasLimited && hasNonLimited) {
|
||||||
result.push_back(kPriceTabLimited);
|
result.push_back(kPriceTabLimited);
|
||||||
}
|
}
|
||||||
|
if (hasResale && hasNonResale) {
|
||||||
|
result.push_back(kPriceTabResale);
|
||||||
|
}
|
||||||
ranges::sort(begin(result) + 1, end(result));
|
ranges::sort(begin(result) + 1, end(result));
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
@ -2832,6 +2845,8 @@ void AddBlock(
|
||||||
const auto pred = [&](const GiftTypeStars &gift) {
|
const auto pred = [&](const GiftTypeStars &gift) {
|
||||||
return (price == kPriceTabLimited)
|
return (price == kPriceTabLimited)
|
||||||
? (!gift.info.limitedCount)
|
? (!gift.info.limitedCount)
|
||||||
|
: (price == kPriceTabResale)
|
||||||
|
? !gift.resale
|
||||||
: (price == kPriceTabInStock)
|
: (price == kPriceTabInStock)
|
||||||
? IsSoldOut(gift.info)
|
? IsSoldOut(gift.info)
|
||||||
: (price && gift.info.stars != price);
|
: (price && gift.info.stars != price);
|
||||||
|
|
Loading…
Add table
Reference in a new issue