diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 61b2a61ac..7f81eed58 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2079,29 +2079,11 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } if (hasWhoReactedItem) { - const auto participantChosen = [=](uint64 id) { - controller->showPeerInfo(PeerId(id)); - }; - const auto weak = Ui::MakeWeak(_menu.get()); - const auto showAllChosen = [=, id = _dragStateItem->fullId()] { - // Pressing on an item that has a submenu doesn't hide it :( - if (const auto strong = weak.data()) { - strong->hideMenu(); - } - if (const auto item = controller->session().data().message(id)) { - controller->window().show(HistoryView::ReactionsListBox( - controller, - item)); - } - }; - if (!_menu->empty()) { - _menu->addSeparator(); - } - _menu->addAction(Ui::WhoReactedContextAction( - _menu.get(), - Api::WhoReacted(_dragStateItem, this, st::defaultWhoRead), - participantChosen, - showAllChosen)); + HistoryView::AddWhoReactedAction( + _menu, + this, + _dragStateItem, + _controller); } if (_menu->empty()) { diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index d53b4f5f3..5d3c36df1 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_attached_stickers.h" #include "api/api_editing.h" #include "api/api_polls.h" +#include "api/api_who_reacted.h" #include "api/api_toggling_media.h" // Api::ToggleFavedSticker #include "base/unixtime.h" #include "history/view/history_view_list_widget.h" @@ -21,10 +22,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_schedule_box.h" #include "history/view/media/history_view_media.h" #include "history/view/media/history_view_web_page.h" +#include "history/view/reactions/message_reactions_list.h" #include "ui/widgets/popup_menu.h" #include "ui/image/image.h" #include "ui/toast/toast.h" #include "ui/controls/delete_message_context_action.h" +#include "ui/controls/who_reacted_context_action.h" #include "ui/boxes/report_box.h" #include "ui/ui_utility.h" #include "chat_helpers/send_context_menu.h" @@ -53,6 +56,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session_settings.h" #include "apiwrap.h" #include "facades.h" +#include "styles/style_chat.h" #include "styles/style_menu_icons.h" #include @@ -913,10 +917,6 @@ ContextMenuRequest::ContextMenuRequest( base::unique_qptr FillContextMenu( not_null list, const ContextMenuRequest &request) { - auto result = base::make_unique_q( - list, - st::popupMenuWithIcons); - const auto link = request.link; const auto view = request.view; const auto item = request.item; @@ -933,6 +933,11 @@ base::unique_qptr FillContextMenu( : nullptr; const auto hasSelection = !request.selectedItems.empty() || !request.selectedText.empty(); + const auto hasWhoReactedItem = item && Api::WhoReactedExists(item); + + auto result = base::make_unique_q( + list, + hasWhoReactedItem ? st::whoReadMenu : st::popupMenuWithIcons); if (request.overSelection && !list->hasCopyRestrictionForSelected()) { const auto text = request.selectedItems.empty() @@ -981,6 +986,11 @@ base::unique_qptr FillContextMenu( AddCopyLinkAction(result, link); AddMessageActions(result, request, list); + + if (hasWhoReactedItem) { + AddWhoReactedAction(result, list, item, list->controller()); + } + return result; } @@ -1060,6 +1070,34 @@ void AddPollActions( } } +void AddWhoReactedAction( + not_null menu, + not_null context, + not_null item, + not_null controller) { + const auto participantChosen = [=](uint64 id) { + controller->showPeerInfo(PeerId(id)); + }; + const auto weak = Ui::MakeWeak(menu.get()); + const auto showAllChosen = [=, itemId = item->fullId()]{ + // Pressing on an item that has a submenu doesn't hide it :( + if (const auto strong = weak.data()) { + strong->hideMenu(); + } + if (const auto item = controller->session().data().message(itemId)) { + controller->window().show(ReactionsListBox(controller, item)); + } + }; + if (!menu->empty()) { + menu->addSeparator(); + } + menu->addAction(Ui::WhoReactedContextAction( + menu.get(), + Api::WhoReacted(item, context, st::defaultWhoRead), + participantChosen, + showAllChosen)); +} + void ShowReportItemsBox(not_null peer, MessageIdsList ids) { const auto chosen = [=](Ui::ReportReason reason) { Ui::show(Box(Ui::ReportDetailsBox, [=](const QString &text) { diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.h b/Telegram/SourceFiles/history/view/history_view_context_menu.h index b95f8ad7f..54ec85d63 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.h +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.h @@ -60,6 +60,11 @@ void AddPollActions( not_null poll, not_null item, Context context); +void AddWhoReactedAction( + not_null menu, + not_null context, + not_null item, + not_null controller); void ShowReportItemsBox(not_null peer, MessageIdsList ids); void ShowReportPeerBox(