Don't suggest "Set As Quick" on already quick.

This commit is contained in:
John Preston 2022-01-17 19:20:38 +03:00
parent 4d11ad45db
commit 9a451a1423
5 changed files with 28 additions and 14 deletions

View File

@ -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();

View File

@ -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<Ui::WhoReactedListMenu>(
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);

View File

@ -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

View File

@ -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<Ui::PopupMenu>(
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(

View File

@ -177,7 +177,10 @@ public:
-> not_null<Ui::ReactionEffectPainter*>;
void recordCurrentReactionEffect(FullMsgId itemId, QPoint origin);
bool showContextMenu(QWidget *parent, QContextMenuEvent *e);
bool showContextMenu(
QWidget *parent,
QContextMenuEvent *e,
const QString &favorite);
[[nodiscard]] rpl::producer<QString> faveRequests() const;
[[nodiscard]] rpl::lifetime &lifetime() {