diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 864c4a3244..3f521b1947 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3836,6 +3836,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_gift_limited_of_one" = "unique"; "lng_gift_limited_of_count" = "1 of {amount}"; "lng_gift_collectible_tag" = "gift"; +"lng_gift_burned_tag" = "burned"; "lng_gift_crafted_tag" = "crafted"; "lng_gift_uncommon_tag" = "uncommon"; "lng_gift_rare_tag" = "rare"; @@ -3847,6 +3848,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_gift_hidden_hint" = "This gift is hidden. Only you can see it."; "lng_gift_hidden_unique" = "This gift is not displayed on your page."; "lng_gift_visible_hint" = "This gift is visible on your page."; +"lng_gift_burned_message" = "This gift was burned in crafting."; "lng_gift_hidden_hint_channel" = "This gift is hidden from visitors of your channel."; "lng_gift_visible_hint_channel" = "This gift is visible in your channel's Gifts."; "lng_gift_in_blockchain" = "This gift is in TON blockchain. {link}"; diff --git a/Telegram/SourceFiles/api/api_premium.cpp b/Telegram/SourceFiles/api/api_premium.cpp index ea235dbb0b..3b3f86bc61 100644 --- a/Telegram/SourceFiles/api/api_premium.cpp +++ b/Telegram/SourceFiles/api/api_premium.cpp @@ -953,6 +953,7 @@ std::optional FromTL( .onlyAcceptTon = data.is_resale_ton_only(), .canBeTheme = data.is_theme_available(), .crafted = data.is_crafted(), + .burned = data.is_burned(), .model = *model, .pattern = *pattern, .value = (data.vvalue_amount() diff --git a/Telegram/SourceFiles/boxes/star_gift_craft_box.cpp b/Telegram/SourceFiles/boxes/star_gift_craft_box.cpp index df92abfd38..1d66618736 100644 --- a/Telegram/SourceFiles/boxes/star_gift_craft_box.cpp +++ b/Telegram/SourceFiles/boxes/star_gift_craft_box.cpp @@ -998,7 +998,19 @@ void Craft( )).done([=](const MTPUpdates &result) { session->api().applyUpdates(result); session->data().nextForUpgradeGiftInvalidate(session->user()); - done(FindUniqueGift(session, result)); + const auto gift = FindUniqueGift(session, result); + const auto slug = gift ? gift->info.unique->slug : QString(); + for (const auto &input : gifts) { + const auto action = (slug == input.unique->slug) + ? Data::GiftUpdate::Action::Upgraded + : Data::GiftUpdate::Action::Delete; + controller->session().data().notifyGiftUpdate({ + .id = input.manageId, + .slug = input.unique->slug, + .action = action, + }); + } + done(gift); }).fail([=](const MTP::Error &error) { const auto type = error.type(); const auto waitPrefix = u"STARGIFT_CRAFT_TOO_EARLY_"_q; diff --git a/Telegram/SourceFiles/data/data_session.h b/Telegram/SourceFiles/data/data_session.h index eb460302b6..d4096e7845 100644 --- a/Telegram/SourceFiles/data/data_session.h +++ b/Telegram/SourceFiles/data/data_session.h @@ -104,6 +104,7 @@ struct GiftUpdate { Pin, Unpin, ResaleChange, + Upgraded, }; Data::SavedStarGiftId id; diff --git a/Telegram/SourceFiles/data/data_star_gift.h b/Telegram/SourceFiles/data/data_star_gift.h index 1153dae5ce..7cd0b73cca 100644 --- a/Telegram/SourceFiles/data/data_star_gift.h +++ b/Telegram/SourceFiles/data/data_star_gift.h @@ -135,6 +135,7 @@ struct UniqueGift { bool onlyAcceptTon = false; bool canBeTheme = false; bool crafted = false; + bool burned = false; TimeId exportAt = 0; TimeId canTransferAt = 0; TimeId canResellAt = 0; diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 7d935c9a25..ee803e75cf 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -1296,9 +1296,7 @@ void History::applyServiceChanges( .text = tr::lng_payments_success( tr::now, lt_amount, - Ui::Text::Wrapped( - payment->amount, - EntityType::Bold), + Ui::Text::Wrapped(payment->amount, EntityType::Bold), lt_title, tr::bold(paid->title), tr::marked), diff --git a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp index 9d5e22f049..63c98b5aac 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp @@ -361,11 +361,15 @@ void PremiumGift::draw( QImage PremiumGift::cornerTag(const PaintContext &context) { auto badge = Info::PeerGifts::GiftBadge(); if (_data.unique) { + const auto burned = _data.unique->burned; + const auto burnedBg = Info::PeerGifts::BurnedBadgeBg(); badge = { - .text = tr::lng_gift_collectible_tag(tr::now), - .bg1 = _data.unique->backdrop.edgeColor, - .bg2 = _data.unique->backdrop.patternColor, - .fg = QColor(255, 255, 255), + .text = (burned + ? tr::lng_gift_burned_tag(tr::now) + : tr::lng_gift_collectible_tag(tr::now)), + .bg1 = (burned ? burnedBg : _data.unique->backdrop.edgeColor), + .bg2 = (burned ? burnedBg : _data.unique->backdrop.patternColor), + .fg = (burned ? st::white->c : _data.unique->backdrop.textColor), }; } else if (const auto count = _data.limitedCount) { badge = { @@ -528,6 +532,9 @@ ClickHandlerPtr OpenStarGiftLink(not_null item) { const auto controller = weak.get(); if (!controller) { return; + } else if (data.unique && data.unique->burned) { + controller->showToast(tr::lng_gift_burned_message(tr::now)); + return; } const auto quick = [=](not_null window) { Settings::ShowStarGiftViewBox(window, data, itemId); diff --git a/Telegram/SourceFiles/history/view/media/history_view_unique_gift.cpp b/Telegram/SourceFiles/history/view/media/history_view_unique_gift.cpp index 6e9363b92e..eb39ee065d 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_unique_gift.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_unique_gift.cpp @@ -495,11 +495,16 @@ auto UniqueGiftBg( ? QMargins() : st::chatUniqueGiftBadgePadding; p.setClipRect(inner.marginsAdded(padding)); + + const auto burned = gift->burned; + const auto burnedBg = Info::PeerGifts::BurnedBadgeBg(); auto badge = Info::PeerGifts::GiftBadge{ - .text = tr::lng_gift_collectible_tag(tr::now), - .bg1 = gift->backdrop.edgeColor, - .bg2 = gift->backdrop.patternColor, - .fg = gift->backdrop.textColor, + .text = (burned + ? tr::lng_gift_burned_tag(tr::now) + : tr::lng_gift_collectible_tag(tr::now)), + .bg1 = (burned ? burnedBg : gift->backdrop.edgeColor), + .bg2 = (burned ? burnedBg : gift->backdrop.patternColor), + .fg = (burned ? st::white->c : gift->backdrop.textColor), }; if (state->badgeCache.isNull() || state->badgeKey != badge) { state->badgeKey = badge; diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp index 3159a52b5b..1a29475a52 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp @@ -1519,4 +1519,8 @@ void SelectGiftToUnpin( })); } +QColor BurnedBadgeBg() { + return QColor(0xd0, 0x3a, 0x3b); +} + } // namespace Info::PeerGifts diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h index ef56e79d8d..93c563b4ee 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h @@ -324,4 +324,6 @@ void SelectGiftToUnpin( const std::vector &pinned, Fn chosen); +[[nodiscard]] QColor BurnedBadgeBg(); + } // namespace Info::PeerGifts diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp index 198c78000d..8e1d863418 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp @@ -200,6 +200,7 @@ private: void subscribeToUpdates(); void applyUpdateTo(Entries &entries, const Data::GiftUpdate &update); + void switchTo(int collectionId); void loadCollections(); void loadMore(); void loaded(const MTPpayments_SavedStarGifts &result); @@ -390,17 +391,20 @@ InnerWidget::InnerWidget( _descriptor.value( ) | rpl::on_next([=](Descriptor now) { - const auto id = now.collectionId; - _collectionsLoadedCallback = nullptr; - _api.request(base::take(_loadMoreRequestId)).cancel(); - _entries = id ? &_perCollection[id] : &_all; - _list = &_entries->list; - refreshButtons(); - refreshAbout(); - loadMore(); + switchTo(now.collectionId); }, lifetime()); } +void InnerWidget::switchTo(int collectionId) { + _collectionsLoadedCallback = nullptr; + _api.request(base::take(_loadMoreRequestId)).cancel(); + _entries = collectionId ? &_perCollection[collectionId] : &_all; + _list = &_entries->list; + refreshButtons(); + refreshAbout(); + loadMore(); +} + void InnerWidget::loadCollections() { if (_addingToCollectionId) { return; @@ -433,7 +437,9 @@ void InnerWidget::subscribeToUpdates() { ) | rpl::on_next([=](const Data::GiftUpdate &update) { applyUpdateTo(_all, update); using Action = Data::GiftUpdate::Action; - if (update.action == Action::Pin || update.action == Action::Unpin) { + if (update.action == Action::Pin + || update.action == Action::Unpin + || update.action == Action::Delete) { for (auto &[_, entries] : _perCollection) { applyUpdateTo(entries, update); } @@ -504,6 +510,9 @@ void InnerWidget::applyUpdateTo( view.manageId = {}; } } + } else if (update.action == Action::Upgraded) { + _scrollToTop.fire({}); + reloadCollection(_descriptor.current().collectionId); } else { return; }