diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 106dce71e..61c7c7237 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -3874,7 +3874,7 @@ void HistoryWidget::send(Api::SendOptions options) { ? _previewData->id : WebPageId(0)); - auto message = ApiWrap::MessageToSend(prepareSendAction(options)); + auto message = Api::MessageToSend(prepareSendAction(options)); message.textWithTags = _field->getTextWithAppliedMarkdown(); message.webPageId = webPageId; diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index fc94a905c..4813dcc5b 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -1166,7 +1166,7 @@ void RepliesWidget::send(Api::SendOptions options) { const auto webPageId = _composeControls->webPageId(); - auto message = ApiWrap::MessageToSend(prepareSendAction(options)); + auto message = Api::MessageToSend(prepareSendAction(options)); message.textWithTags = _composeControls->getTextWithAppliedMarkdown(); message.webPageId = webPageId; @@ -2507,8 +2507,7 @@ void RepliesWidget::listSendBotCommand( _history->peer, command, context); - auto message = ApiWrap::MessageToSend( - prepareSendAction({})); + auto message = Api::MessageToSend(prepareSendAction({})); message.textWithTags = { text }; session().api().sendMessage(std::move(message)); finishSending(); diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index 998909301..c8966ad9c 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -587,7 +587,7 @@ void ScheduledWidget::send() { void ScheduledWidget::send(Api::SendOptions options) { const auto webPageId = _composeControls->webPageId(); - auto message = ApiWrap::MessageToSend(prepareSendAction(options)); + auto message = Api::MessageToSend(prepareSendAction(options)); message.textWithTags = _composeControls->getTextWithAppliedMarkdown(); message.webPageId = webPageId; @@ -1235,7 +1235,7 @@ void ScheduledWidget::listSendBotCommand( _history->peer, command, context); - auto message = ApiWrap::MessageToSend(prepareSendAction(options)); + auto message = Api::MessageToSend(prepareSendAction(options)); message.textWithTags = { text }; session().api().sendMessage(std::move(message)); }; diff --git a/Telegram/SourceFiles/media/stories/media_stories_controller.cpp b/Telegram/SourceFiles/media/stories/media_stories_controller.cpp index 6ea4a3f82..9131724f2 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_controller.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_controller.cpp @@ -167,6 +167,11 @@ Controller::Controller(not_null delegate) } }, _lifetime); + _reactions->chosen( + ) | rpl::start_with_next([=](const Data::ReactionId &id) { + _replyArea->sendReaction(id); + }, _lifetime); + _delegate->storiesLayerShown( ) | rpl::start_with_next([=](bool shown) { _layerShown = shown; diff --git a/Telegram/SourceFiles/media/stories/media_stories_reactions.cpp b/Telegram/SourceFiles/media/stories/media_stories_reactions.cpp index 49434bd53..d77e8274e 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_reactions.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_reactions.cpp @@ -143,9 +143,8 @@ void Reactions::create() { _selector->chosen( ) | rpl::start_with_next([=]( HistoryView::Reactions::ChosenReaction reaction) { + _chosen.fire_copy(reaction.id); hide(); - //reaction.context = itemId; - //chosen(std::move(reaction)); }, _selector->lifetime()); _selector->premiumPromoChosen() | rpl::start_with_next([=] { diff --git a/Telegram/SourceFiles/media/stories/media_stories_reactions.h b/Telegram/SourceFiles/media/stories/media_stories_reactions.h index e9a89a09c..1be44b34a 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_reactions.h +++ b/Telegram/SourceFiles/media/stories/media_stories_reactions.h @@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/animations.h" +namespace Data { +struct ReactionId; +} // namespace Data + namespace HistoryView::Reactions { class Selector; } // namespace HistoryView::Reactions @@ -29,6 +33,9 @@ public: [[nodiscard]] rpl::producer expandedValue() const { return _expanded.value(); } + [[nodiscard]] rpl::producer chosen() const { + return _chosen.events(); + } void show(); void hide(); @@ -47,6 +54,7 @@ private: std::unique_ptr _parent; std::unique_ptr _selector; std::vector> _hiding; + rpl::event_stream _chosen; Ui::Animations::Simple _showing; rpl::variable _shownValue; rpl::variable _expanded; diff --git a/Telegram/SourceFiles/media/stories/media_stories_reply.cpp b/Telegram/SourceFiles/media/stories/media_stories_reply.cpp index db914d816..1ccce96a6 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_reply.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_reply.cpp @@ -17,6 +17,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "chat_helpers/tabbed_selector.h" #include "core/file_utilities.h" #include "core/mime_type.h" +#include "data/stickers/data_custom_emoji.h" +#include "data/data_document.h" +#include "data/data_message_reaction_id.h" #include "data/data_session.h" #include "data/data_user.h" #include "history/view/controls/compose_controls_common.h" @@ -101,13 +104,39 @@ void ReplyArea::initGeometry() { }, _lifetime); } +void ReplyArea::sendReaction(const Data::ReactionId &id) { + Expects(_data.user != nullptr); + + auto message = Api::MessageToSend(prepareSendAction({})); + if (const auto emoji = id.emoji(); !emoji.isEmpty()) { + message.textWithTags = { emoji }; + } else if (const auto customId = id.custom()) { + const auto document = _data.user->owner().document(customId); + if (const auto sticker = document->sticker()) { + const auto text = sticker->alt; + const auto id = Data::SerializeCustomEmojiId(customId); + message.textWithTags = { + text, + { { 0, text.size(), Ui::InputField::CustomEmojiLink(id) } } + }; + } + } + if (!message.textWithTags.empty()) { + send(std::move(message), {}); + } +} + void ReplyArea::send(Api::SendOptions options) { const auto webPageId = _controls->webPageId(); - auto message = ApiWrap::MessageToSend(prepareSendAction(options)); + auto message = Api::MessageToSend(prepareSendAction(options)); message.textWithTags = _controls->getTextWithAppliedMarkdown(); message.webPageId = webPageId; + send(std::move(message), options); +} + +void ReplyArea::send(Api::MessageToSend message, Api::SendOptions options) { const auto error = GetErrorTextForSending( _data.user, { diff --git a/Telegram/SourceFiles/media/stories/media_stories_reply.h b/Telegram/SourceFiles/media/stories/media_stories_reply.h index 30d15cb28..4dcd84013 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_reply.h +++ b/Telegram/SourceFiles/media/stories/media_stories_reply.h @@ -15,8 +15,13 @@ enum class SendMediaType; namespace Api { struct SendAction; struct SendOptions; +struct MessageToSend; } // namespace Api +namespace Data { +struct ReactionId; +} // namespace Data + namespace HistoryView { class ComposeControls; } // namespace HistoryView @@ -56,6 +61,7 @@ public: ~ReplyArea(); void show(ReplyAreaData data); + void sendReaction(const Data::ReactionId &id); [[nodiscard]] rpl::producer focusedValue() const; [[nodiscard]] rpl::producer activeValue() const; @@ -67,6 +73,8 @@ private: [[nodiscard]] Main::Session &session() const; [[nodiscard]] not_null history() const; + void send(Api::MessageToSend message, Api::SendOptions options); + void uploadFile(const QByteArray &fileContent, SendMediaType type); bool confirmSendingFiles( QImage &&image,