diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index f2ad99f46..4f04b0266 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -457,7 +457,8 @@ void GifsListWidget::mouseReleaseEvent(QMouseEvent *e) { void GifsListWidget::selectInlineResult( int index, Api::SendOptions options, - bool forceSend) { + bool forceSend, + TextWithTags caption) { const auto item = _mosaic.maybeItemAt(index); if (!item) { return; @@ -498,6 +499,7 @@ void GifsListWidget::selectInlineResult( .document = document, .options = options, .messageSendingFrom = messageSendingFrom(), + .caption = std::move(caption), }); } else if (!preview.usingThumbnail()) { if (preview.loading()) { diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.h b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.h index ad6c26ae6..249ba5d0c 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.h +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.h @@ -172,7 +172,8 @@ private: void selectInlineResult( int index, Api::SendOptions options, - bool forceSend = false); + bool forceSend = false, + TextWithTags caption = {}); const std::shared_ptr _show; std::unique_ptr _search; diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.h b/Telegram/SourceFiles/chat_helpers/tabbed_selector.h index b5355dafc..f17129903 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.h +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.h @@ -62,6 +62,7 @@ struct FileChosen { not_null document; Api::SendOptions options; Ui::MessageSendingAnimationFrom messageSendingFrom; + TextWithTags caption; }; struct PhotoChosen { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 08d94e641..038590217 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1201,7 +1201,13 @@ void HistoryWidget::initTabbedSelector() { controller()->sendingAnimation().appendSending( data.messageSendingFrom); const auto localId = data.messageSendingFrom.localId; - sendExistingDocument(data.document, data.options, localId); + auto messageToSend = Api::MessageToSend( + prepareSendAction(data.options)); + messageToSend.textWithTags = base::take(data.caption); + sendExistingDocument( + data.document, + std::move(messageToSend), + localId); } }, lifetime()); @@ -7458,7 +7464,7 @@ void HistoryWidget::requestMessageData(MsgId msgId) { bool HistoryWidget::sendExistingDocument( not_null document, - Api::SendOptions options, + Api::MessageToSend messageToSend, std::optional localId) { const auto error = _peer ? Data::RestrictionError(_peer, ChatRestriction::SendStickers) @@ -7474,7 +7480,7 @@ bool HistoryWidget::sendExistingDocument( } Api::SendExistingDocument( - Api::MessageToSend(prepareSendAction(options)), + std::move(messageToSend), document, localId); diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index ef17e3285..83b501d30 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -37,6 +37,7 @@ struct Details; } // namespace SendMenu namespace Api { +struct MessageToSend; struct SendOptions; struct SendAction; } // namespace Api @@ -273,7 +274,7 @@ public: [[nodiscard]] SendMenu::Details saveMenuDetails() const; bool sendExistingDocument( not_null document, - Api::SendOptions options, + Api::MessageToSend messageToSend, std::optional localId = std::nullopt); bool sendExistingPhoto( not_null photo, diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index 7e92caa1d..cc243e96a 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -760,8 +760,13 @@ void RepliesWidget::setupComposeControls() { controller()->hideLayer(anim::type::normal); controller()->sendingAnimation().appendSending( data.messageSendingFrom); - const auto localId = data.messageSendingFrom.localId; - sendExistingDocument(data.document, data.options, localId); + auto messageToSend = Api::MessageToSend( + prepareSendAction(data.options)); + messageToSend.textWithTags = base::take(data.caption); + sendExistingDocument( + data.document, + std::move(messageToSend), + data.messageSendingFrom.localId); }, lifetime()); _composeControls->photoChosen( @@ -1327,7 +1332,7 @@ void RepliesWidget::refreshJoinGroupButton() { bool RepliesWidget::sendExistingDocument( not_null document, - Api::SendOptions options, + Api::MessageToSend messageToSend, std::optional localId) { const auto error = Data::RestrictionError( _history->peer, @@ -1341,7 +1346,7 @@ bool RepliesWidget::sendExistingDocument( } Api::SendExistingDocument( - Api::MessageToSend(prepareSendAction(options)), + std::move(messageToSend), document, localId); diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.h b/Telegram/SourceFiles/history/view/history_view_replies_section.h index b7c8cc164..be572f4ca 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.h +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.h @@ -23,6 +23,7 @@ struct Details; } // namespace SendMenu namespace Api { +struct MessageToSend; struct SendOptions; struct SendAction; } // namespace Api @@ -303,7 +304,7 @@ private: bool sendExistingDocument( not_null document, - Api::SendOptions options, + Api::MessageToSend messageToSend, std::optional localId); void sendExistingPhoto(not_null photo); bool sendExistingPhoto( diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index be744824a..883b04030 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -342,7 +342,10 @@ void ScheduledWidget::setupComposeControls() { controller()->hideLayer(anim::type::normal); const auto document = data.document; const auto callback = crl::guard(this, [=](Api::SendOptions options) { - sendExistingDocument(document, options); + auto messageToSend = Api::MessageToSend( + prepareSendAction(options)); + messageToSend.textWithTags = data.caption; + sendExistingDocument(document, std::move(messageToSend)); }); controller()->show( PrepareScheduleBox(this, _show, sendMenuDetails(), callback)); @@ -815,7 +818,7 @@ void ScheduledWidget::edit( bool ScheduledWidget::sendExistingDocument( not_null document, - Api::SendOptions options) { + Api::MessageToSend messageToSend) { const auto error = Data::RestrictionError( _history->peer, ChatRestriction::SendStickers); @@ -826,9 +829,7 @@ bool ScheduledWidget::sendExistingDocument( return false; } - Api::SendExistingDocument( - Api::MessageToSend(prepareSendAction(options)), - document); + Api::SendExistingDocument(std::move(messageToSend), document); _composeControls->hidePanelsAnimated(); _composeControls->focus(); diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.h b/Telegram/SourceFiles/history/view/history_view_scheduled_section.h index 519a45dfb..0a7ff39b0 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.h +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.h @@ -26,6 +26,7 @@ struct Details; } // namespace SendMenu namespace Api { +struct MessageToSend; struct SendOptions; struct SendAction; } // namespace Api @@ -253,7 +254,7 @@ private: bool sendExistingDocument( not_null document, - Api::SendOptions options); + Api::MessageToSend messageToSend); void sendExistingPhoto(not_null photo); bool sendExistingPhoto( not_null photo, diff --git a/Telegram/SourceFiles/media/stories/media_stories_reply.cpp b/Telegram/SourceFiles/media/stories/media_stories_reply.cpp index d93f49bf1..136c77b7a 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_reply.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_reply.cpp @@ -252,7 +252,7 @@ void ReplyArea::sendVoice(VoiceToSend &&data) { bool ReplyArea::sendExistingDocument( not_null document, - Api::SendOptions options, + Api::MessageToSend messageToSend, std::optional localId) { Expects(_data.peer != nullptr); @@ -268,10 +268,7 @@ bool ReplyArea::sendExistingDocument( return false; } - Api::SendExistingDocument( - Api::MessageToSend(prepareSendAction(options)), - document, - localId); + Api::SendExistingDocument(std::move(messageToSend), document, localId); _controls->cancelReplyMessage(); finishSending(); @@ -633,8 +630,13 @@ void ReplyArea::initActions() { _controls->fileChosen( ) | rpl::start_with_next([=](ChatHelpers::FileChosen data) { _controller->uiShow()->hideLayer(); - const auto localId = data.messageSendingFrom.localId; - sendExistingDocument(data.document, data.options, localId); + auto messageToSend = Api::MessageToSend( + prepareSendAction(data.options)); + messageToSend.textWithTags = base::take(data.caption); + sendExistingDocument( + data.document, + std::move(messageToSend), + data.messageSendingFrom.localId); }, _lifetime); _controls->photoChosen( diff --git a/Telegram/SourceFiles/media/stories/media_stories_reply.h b/Telegram/SourceFiles/media/stories/media_stories_reply.h index 445557692..981cc48c1 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_reply.h +++ b/Telegram/SourceFiles/media/stories/media_stories_reply.h @@ -13,9 +13,9 @@ class History; enum class SendMediaType; namespace Api { +struct MessageToSend; struct SendAction; struct SendOptions; -struct MessageToSend; } // namespace Api namespace Data { @@ -120,7 +120,7 @@ private: bool sendExistingDocument( not_null document, - Api::SendOptions options, + Api::MessageToSend messageToSend, std::optional localId); void sendExistingPhoto(not_null photo); bool sendExistingPhoto(