diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index f2aa178cc..0f8b66c68 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -1852,7 +1852,10 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { const auto link = ClickHandler::getActive(); if (link && !link->property(kSendReactionEmojiProperty).toString().isEmpty() - && _reactionsManager->showContextMenu(this, e)) { + && _reactionsManager->showContextMenu( + this, + e, + session().data().reactions().favorite())) { return; } auto selectedState = getSelectionState(); diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index 45a8bc5db..4caee48a7 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -1126,10 +1126,8 @@ void ShowWhoReactedMenu( const auto reactions = &controller->session().data().reactions(); const auto &list = reactions->list( Data::Reactions::Type::Active); - const auto active = ranges::contains( - list, - emoji, - &Data::Reaction::emoji); + const auto activeNonQuick = (emoji != reactions->favorite()) + && ranges::contains(list, emoji, &Data::Reaction::emoji); const auto filler = lifetime.make_state( participantChosen, showAllChosen); @@ -1143,7 +1141,7 @@ void ShowWhoReactedMenu( }) | rpl::start_with_next([=, &lifetime](Ui::WhoReadContent &&content) { const auto creating = !*menu; const auto refill = [=] { - if (active) { + if (activeNonQuick) { (*menu)->addAction(tr::lng_context_set_as_quick(tr::now), [=] { reactions->setFavorite(emoji); }, &st::menuIconFave); diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 13b58ca66..e7e6fbf9c 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -2096,7 +2096,10 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { const auto link = ClickHandler::getActive(); if (link && !link->property(kSendReactionEmojiProperty).toString().isEmpty() - && _reactionsManager->showContextMenu(this, e)) { + && _reactionsManager->showContextMenu( + this, + e, + session().data().reactions().favorite())) { return; } const auto overItem = _overItemExact diff --git a/Telegram/SourceFiles/history/view/history_view_react_button.cpp b/Telegram/SourceFiles/history/view/history_view_react_button.cpp index 3280863a0..d6ea41727 100644 --- a/Telegram/SourceFiles/history/view/history_view_react_button.cpp +++ b/Telegram/SourceFiles/history/view/history_view_react_button.cpp @@ -1553,19 +1553,26 @@ void Manager::recordCurrentReactionEffect(FullMsgId itemId, QPoint origin) { } } -bool Manager::showContextMenu(QWidget *parent, QContextMenuEvent *e) { +bool Manager::showContextMenu( + QWidget *parent, + QContextMenuEvent *e, + const QString &favorite) { if (_icons.empty() || _selectedIcon < 0) { return false; } + const auto lookupSelectedEmoji = [&] { + const auto i = ranges::find(_icons, true, &ReactionIcons::selected); + return (i != end(_icons)) ? (*i)->emoji : QString(); + }; + if (!favorite.isEmpty() && lookupSelectedEmoji() == favorite) { + return true; + } _menu = base::make_unique_q( parent, st::popupMenuWithIcons); const auto callback = [=] { - for (const auto &icon : _icons) { - if (icon->selected) { - _faveRequests.fire_copy(icon->emoji); - return; - } + if (const auto emoji = lookupSelectedEmoji(); !emoji.isEmpty()) { + _faveRequests.fire_copy(emoji); } }; _menu->addAction( diff --git a/Telegram/SourceFiles/history/view/history_view_react_button.h b/Telegram/SourceFiles/history/view/history_view_react_button.h index dbe80fb6e..cc9c056fd 100644 --- a/Telegram/SourceFiles/history/view/history_view_react_button.h +++ b/Telegram/SourceFiles/history/view/history_view_react_button.h @@ -177,7 +177,10 @@ public: -> not_null; void recordCurrentReactionEffect(FullMsgId itemId, QPoint origin); - bool showContextMenu(QWidget *parent, QContextMenuEvent *e); + bool showContextMenu( + QWidget *parent, + QContextMenuEvent *e, + const QString &favorite); [[nodiscard]] rpl::producer faveRequests() const; [[nodiscard]] rpl::lifetime &lifetime() {