diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index f0971a3627..471b273fa4 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -31,7 +31,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "window/window_session_controller.h" #include "history/view/history_view_cursor_state.h" -#include "history/view/history_view_schedule_box.h" #include "app.h" #include "storage/storage_account.h" // Account::writeSavedGifs #include "styles/style_chat_helpers.h" @@ -376,20 +375,11 @@ void GifsListWidget::fillContextMenu( const auto send = [=](Api::SendOptions options) { selectInlineResult(row, column, options, true); }; - const auto silent = [=] { send({ .silent = true }); }; - const auto schedule = [=] { - Ui::show( - HistoryView::PrepareScheduleBox( - this, - type, - [=](Api::SendOptions options) { send(options); }), - Ui::LayerOption::KeepOther); - }; FillSendMenu( menu, [&] { return type; }, - silent, - schedule); + DefaultSilentCallback(send), + DefaultScheduleCallback(this, type, send)); [&] { const auto row = _selected / MatrixRowShift; diff --git a/Telegram/SourceFiles/chat_helpers/send_context_menu.cpp b/Telegram/SourceFiles/chat_helpers/send_context_menu.cpp index 4add9f2139..f0a60ddb0e 100644 --- a/Telegram/SourceFiles/chat_helpers/send_context_menu.cpp +++ b/Telegram/SourceFiles/chat_helpers/send_context_menu.cpp @@ -9,12 +9,33 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_common.h" #include "base/event_filter.h" +#include "boxes/abstract_box.h" #include "core/shortcuts.h" +#include "history/view/history_view_schedule_box.h" #include "lang/lang_keys.h" #include "ui/widgets/popup_menu.h" #include +Fn DefaultSilentCallback(Fn send) { + return [=] { send({ .silent = true }); }; +} + +Fn DefaultScheduleCallback( + not_null parent, + SendMenuType type, + Fn send) { + const auto weak = Ui::MakeWeak(parent); + return [=] { + Ui::show( + HistoryView::PrepareScheduleBox( + weak, + type, + [=](Api::SendOptions options) { send(options); }), + Ui::LayerOption::KeepOther); + }; +} + FillMenuResult FillSendMenu( not_null menu, Fn type, diff --git a/Telegram/SourceFiles/chat_helpers/send_context_menu.h b/Telegram/SourceFiles/chat_helpers/send_context_menu.h index cd221f1a31..382d5cafab 100644 --- a/Telegram/SourceFiles/chat_helpers/send_context_menu.h +++ b/Telegram/SourceFiles/chat_helpers/send_context_menu.h @@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" +namespace Api { +struct SendOptions; +} // namespace Api + namespace Ui { class PopupMenu; } // namespace Ui @@ -26,6 +30,12 @@ enum class FillMenuResult { None, }; +Fn DefaultSilentCallback(Fn send); +Fn DefaultScheduleCallback( + not_null parent, + SendMenuType type, + Fn send); + FillMenuResult FillSendMenu( not_null menu, Fn type, diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 92bb0b1b14..7fc2021cb4 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -26,7 +26,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lottie/lottie_animation.h" #include "boxes/stickers_box.h" #include "inline_bots/inline_bot_result.h" -#include "history/view/history_view_schedule_box.h" #include "storage/storage_account.h" #include "lang/lang_keys.h" #include "mainwindow.h" @@ -2073,20 +2072,11 @@ void StickersListWidget::fillContextMenu( .document = document, .options = options }); }; - const auto silent = [=] { send({ .silent = true }); }; - const auto schedule = [=] { - checkHideWithBox(Ui::show( - HistoryView::PrepareScheduleBox( - this, - type, - [=](Api::SendOptions options) { send(options); }), - Ui::LayerOption::KeepOther).data()); - }; FillSendMenu( menu, [&] { return type; }, - silent, - schedule); + DefaultSilentCallback(send), + DefaultScheduleCallback(this, type, send)); const auto toggleFavedSticker = [=] { document->session().api().toggleFavedSticker( diff --git a/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp b/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp index 6fb589b809..157a5169e5 100644 --- a/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp @@ -34,7 +34,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/scroll_area.h" #include "ui/widgets/labels.h" #include "history/view/history_view_cursor_state.h" -#include "history/view/history_view_schedule_box.h" #include "facades.h" #include "app.h" #include "styles/style_chat_helpers.h" @@ -312,20 +311,11 @@ void Inner::contextMenuEvent(QContextMenuEvent *e) { const auto send = [=](Api::SendOptions options) { selectInlineResult(row, column, options); }; - const auto silent = [=] { send({ .silent = true }); }; - const auto schedule = [=] { - Ui::show( - HistoryView::PrepareScheduleBox( - this, - type, - [=](Api::SendOptions options) { send(options); }), - Ui::LayerOption::KeepOther); - }; FillSendMenu( _menu, [&] { return type; }, - silent, - schedule); + DefaultSilentCallback(send), + DefaultScheduleCallback(this, type, send)); if (!_menu->actions().empty()) { _menu->popup(QCursor::pos());