From 3549c001417369c1d91e1a68564828f9205e0a1e Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 23 Aug 2025 14:54:58 +0300 Subject: [PATCH] Added ability to forward to Saved Messages on fast action with Ctrl. --- Telegram/SourceFiles/boxes/share_box.cpp | 23 +++++++++++++++++++ Telegram/SourceFiles/boxes/share_box.h | 3 +++ .../history/view/history_view_message.cpp | 3 +++ 3 files changed, 29 insertions(+) diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index 5f9e018a28..4c6eb01e0b 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -1935,6 +1935,29 @@ void FastShareMessage( }), Ui::LayerOption::CloseOther); } +void FastShareMessageToSelf( + std::shared_ptr show, + not_null item) { + const auto self = show->session().user(); + const auto donePhraseArgs = ChatHelpers::ForwardedMessagePhraseArgs{ + .toCount = 1, + .singleMessage = true, + .to1 = self, + .to2 = nullptr, + }; + auto sendAction = Api::SendAction(self->owner().history(self)); + sendAction.clearDraft = false; + show->session().api().forwardMessages( + Data::ResolvedForwardDraft{ .items = {item} }, + std::move(sendAction), + [=] { + auto phrase = rpl::variable( + ChatHelpers::ForwardedMessagePhrase( + donePhraseArgs)).current(); + show->showToast(std::move(phrase)); + }); +} + void FastShareMessage( not_null controller, not_null item, diff --git a/Telegram/SourceFiles/boxes/share_box.h b/Telegram/SourceFiles/boxes/share_box.h index 5cbfb794d7..ec31a835b5 100644 --- a/Telegram/SourceFiles/boxes/share_box.h +++ b/Telegram/SourceFiles/boxes/share_box.h @@ -71,6 +71,9 @@ struct ShareBoxStyleOverrides { }; [[nodiscard]] ShareBoxStyleOverrides DarkShareBoxStyle(); +void FastShareMessageToSelf( + std::shared_ptr show, + not_null item); void FastShareMessage( std::shared_ptr show, not_null item, diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 4391982912..1a82ad8cf2 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_message.h" #include "api/api_suggest_post.h" +#include "base/qt/qt_key_modifiers.h" #include "base/unixtime.h" #include "core/click_handler_types.h" // ClickHandlerContext #include "core/ui_integration.h" @@ -4214,6 +4215,8 @@ ClickHandlerPtr Message::prepareRightActionLink() const { savedFromPeer, Window::SectionShow::Way::Forward, savedFromMsgId); + } else if (base::IsCtrlPressed()) { + FastShareMessageToSelf(controller->uiShow(), item); } else { FastShareMessage(controller, item); }