Improved ability set emoji status locally in profile top bar.

This commit is contained in:
23rd
2025-10-26 19:00:19 +03:00
parent 294ab035f0
commit 9df4377450
3 changed files with 8 additions and 14 deletions
@@ -1857,7 +1857,7 @@ void EditPeerProfileColorSection(
: std::optional<Ui::ColorCollectible>();
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<Ui::ColorCollectible>();
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());
}
@@ -902,14 +902,10 @@ void TopBar::setPatternEmojiId(std::optional<DocumentId> patternEmojiId) {
updateCollectibleStatus();
}
void TopBar::setLocalCollectible(
std::shared_ptr<Data::EmojiStatusCollectible> 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);
}
@@ -116,8 +116,7 @@ public:
void setEnableBackButtonValue(rpl::producer<bool> &&producer);
void setColorProfileIndex(std::optional<uint8> index);
void setPatternEmojiId(std::optional<DocumentId> patternEmojiId);
void setLocalCollectible(
std::shared_ptr<Data::EmojiStatusCollectible> collectible);
void setLocalEmojiStatusId(EmojiStatusId emojiStatusId);
void addTopBarMenuButton(
not_null<Window::SessionController*> controller,
Wrap wrap,