From 9df4377450f511f899d8cd3d85e44f9013557cc0 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 26 Oct 2025 19:00:19 +0300 Subject: [PATCH] Improved ability set emoji status locally in profile top bar. --- .../SourceFiles/boxes/peers/edit_peer_color_box.cpp | 7 +++---- .../info/profile/info_profile_top_bar.cpp | 12 ++++-------- .../SourceFiles/info/profile/info_profile_top_bar.h | 3 +-- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp index f445362147..7bfe468851 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp @@ -1857,7 +1857,7 @@ void EditPeerProfileColorSection( : std::optional(); const auto resetUnique = [=] { - preview->setLocalCollectible(nullptr); + preview->setLocalEmojiStatusId({}); state->buyCollectible = nullptr; state->collectible.force_assign(std::nullopt); }; @@ -1976,9 +1976,8 @@ void EditPeerProfileColorSection( : std::optional(); preview->setColorProfileIndex(std::nullopt); preview->setPatternEmojiId(selected->pattern.document->id); - const auto emojiStatuses = &session->data().emojiStatuses(); - const auto id = emojiStatuses->fromUniqueGift(*selected); - preview->setLocalCollectible(id.collectible); + preview->setLocalEmojiStatusId( + session->data().emojiStatuses().fromUniqueGift(*selected)); resetWrap->toggle(true, anim::type::normal); }, state->collectible.value(), true, state->selectedGiftId.value()); } diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp index 27cc6b77c4..aa7040c8c2 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp @@ -902,14 +902,10 @@ void TopBar::setPatternEmojiId(std::optional patternEmojiId) { updateCollectibleStatus(); } -void TopBar::setLocalCollectible( - std::shared_ptr collectible) { - _localCollectible = collectible; - if (collectible) { - _badgeContent = Badge::Content{ - BadgeType::Premium, - EmojiStatusId{ .collectible = collectible }, - }; +void TopBar::setLocalEmojiStatusId(EmojiStatusId emojiStatusId) { + _localCollectible = emojiStatusId.collectible; + if (emojiStatusId) { + _badgeContent = Badge::Content{ BadgeType::Premium, emojiStatusId }; } else { _badgeContent = BadgeContentForPeer(_peer); } diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h index f11a3d3538..0a0682a201 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h @@ -116,8 +116,7 @@ public: void setEnableBackButtonValue(rpl::producer &&producer); void setColorProfileIndex(std::optional index); void setPatternEmojiId(std::optional patternEmojiId); - void setLocalCollectible( - std::shared_ptr collectible); + void setLocalEmojiStatusId(EmojiStatusId emojiStatusId); void addTopBarMenuButton( not_null controller, Wrap wrap,