diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index 6f21db7db1..4909768bbb 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -165,7 +165,7 @@ GifsListWidget::GifsListWidget( }); } -rpl::producer> GifsListWidget::fileChosen() const { +rpl::producer GifsListWidget::fileChosen() const { return _fileChosen.events(); } @@ -391,7 +391,7 @@ void GifsListWidget::selectInlineResult(int row, int column) { const auto media = document->activeMediaView(); const auto preview = Data::VideoPreviewState(media.get()); if (ctrl || (media && preview.loaded())) { - _fileChosen.fire_copy(document); + _fileChosen.fire_copy({ .document = document }); } else if (!preview.usingThumbnail()) { if (preview.loading()) { document->cancel(); diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.h b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.h index 7a67388b35..84925eb1cc 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.h +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.h @@ -40,7 +40,7 @@ public: GifsListWidget(QWidget *parent, not_null controller); - rpl::producer> fileChosen() const; + rpl::producer fileChosen() const; rpl::producer> photoChosen() const; rpl::producer inlineResultChosen() const; @@ -177,7 +177,7 @@ private: QString _inlineQuery, _inlineNextQuery, _inlineNextOffset; mtpRequestId _inlineRequestId = 0; - rpl::event_stream> _fileChosen; + rpl::event_stream _fileChosen; rpl::event_stream> _photoChosen; rpl::event_stream _inlineResultChosen; rpl::event_stream<> _cancelled; diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index bcd7c2d2a3..ef0ba93f0d 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -913,7 +913,7 @@ Main::Session &StickersListWidget::session() const { return controller()->session(); } -rpl::producer> StickersListWidget::chosen() const { +rpl::producer StickersListWidget::chosen() const { return _chosen.events(); } @@ -2087,7 +2087,7 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) { document)); } } else { - _chosen.fire_copy(document); + _chosen.fire_copy({ .document = document }); } } else if (auto set = base::get_if(&pressed)) { Assert(set->section >= 0 && set->section < sets.size()); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h index 8ac39583ac..9238cfe32f 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h @@ -51,7 +51,7 @@ public: Main::Session &session() const; - rpl::producer> chosen() const; + rpl::producer chosen() const; rpl::producer<> scrollUpdated() const; rpl::producer<> checkForHide() const; @@ -358,7 +358,7 @@ private: QString _searchQuery, _searchNextQuery; mtpRequestId _searchRequestId = 0; - rpl::event_stream> _chosen; + rpl::event_stream _chosen; rpl::event_stream<> _scrollUpdated; rpl::event_stream<> _checkForHide; diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp index a4c7a805ac..132f8ba707 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp @@ -409,10 +409,10 @@ rpl::producer TabbedSelector::emojiChosen() const { return emoji()->chosen(); } -rpl::producer> TabbedSelector::fileChosen() const { +rpl::producer TabbedSelector::fileChosen() const { return full() ? rpl::merge(stickers()->chosen(), gifs()->fileChosen()) - : rpl::never>() | rpl::type_erased(); + : rpl::never() | rpl::type_erased(); } rpl::producer> TabbedSelector::photoChosen() const { diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.h b/Telegram/SourceFiles/chat_helpers/tabbed_selector.h index 6f78129e45..eec1e74fa1 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.h +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.h @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once +#include "api/api_common.h" #include "ui/rp_widget.h" #include "ui/effects/animations.h" #include "ui/effects/panel_animation.h" @@ -46,6 +47,10 @@ class GifsListWidget; class TabbedSelector : public Ui::RpWidget, private base::Subscriber { public: + struct FileChosen { + not_null document; + Api::SendOptions options; + }; struct InlineChosen { not_null result; not_null bot; @@ -64,7 +69,7 @@ public: Main::Session &session() const; rpl::producer emojiChosen() const; - rpl::producer> fileChosen() const; + rpl::producer fileChosen() const; rpl::producer> photoChosen() const; rpl::producer inlineResultChosen() const; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index a36a76b377..2e7a67e918 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -387,7 +387,7 @@ HistoryWidget::HistoryWidget( connect(_fieldAutocomplete, SIGNAL(hashtagChosen(QString,FieldAutocomplete::ChooseMethod)), this, SLOT(onHashtagOrBotCommandInsert(QString,FieldAutocomplete::ChooseMethod))); connect(_fieldAutocomplete, SIGNAL(botCommandChosen(QString,FieldAutocomplete::ChooseMethod)), this, SLOT(onHashtagOrBotCommandInsert(QString,FieldAutocomplete::ChooseMethod))); connect(_fieldAutocomplete, &FieldAutocomplete::stickerChosen, this, [=](not_null document) { - sendExistingDocument(document); + sendExistingDocument(document, Api::SendOptions()); }); connect(_fieldAutocomplete, SIGNAL(moderateKeyActivate(int,bool*)), this, SLOT(onModerateKeyActivate(int,bool*))); if (_supportAutocomplete) { @@ -818,8 +818,8 @@ void HistoryWidget::initTabbedSelector() { selector->fileChosen( ) | rpl::filter([=] { return !isHidden(); - }) | rpl::start_with_next([=](not_null document) { - sendExistingDocument(document); + }) | rpl::start_with_next([=](TabbedSelector::FileChosen data) { + sendExistingDocument(data.document, data.options); }, lifetime()); selector->photoChosen( @@ -5368,7 +5368,9 @@ void HistoryWidget::destroyPinnedBar() { _inPinnedMsg = false; } -bool HistoryWidget::sendExistingDocument(not_null document) { +bool HistoryWidget::sendExistingDocument( + not_null document, + Api::SendOptions options) { const auto error = _peer ? Data::RestrictionError(_peer, ChatRestriction::f_send_stickers) : std::nullopt; @@ -5382,6 +5384,7 @@ bool HistoryWidget::sendExistingDocument(not_null document) { } auto message = Api::MessageToSend(_history); + message.action.options = std::move(options); message.action.replyTo = replyToId(); Api::SendExistingDocument(std::move(message), document); diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 9c5e7e6446..28e9b506da 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -248,7 +248,9 @@ public: void confirmDeleteSelected(); void clearSelected(); - bool sendExistingDocument(not_null document); + bool sendExistingDocument( + not_null document, + Api::SendOptions options); bool sendExistingPhoto(not_null photo); void showInfoTooltip( diff --git a/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp index 7edb1a78e7..a4ac23c379 100644 --- a/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp @@ -39,6 +39,7 @@ namespace HistoryView { namespace { +using FileChosen = ComposeControls::FileChosen; using MessageToEdit = ComposeControls::MessageToEdit; constexpr auto kMouseEvent = { @@ -502,7 +503,7 @@ void ComposeControls::setMimeDataHook(MimeDataHook hook) { _field->setMimeDataHook(std::move(hook)); } -rpl::producer> ComposeControls::fileChosen() const { +rpl::producer ComposeControls::fileChosen() const { return _fileChosen.events(); } diff --git a/Telegram/SourceFiles/history/view/history_view_compose_controls.h b/Telegram/SourceFiles/history/view/history_view_compose_controls.h index 32b8fd80d5..7e9bd2c3fc 100644 --- a/Telegram/SourceFiles/history/view/history_view_compose_controls.h +++ b/Telegram/SourceFiles/history/view/history_view_compose_controls.h @@ -54,6 +54,7 @@ class FieldHeader; class ComposeControls final { public: + using FileChosen = ChatHelpers::TabbedSelector::FileChosen; enum class Mode { Normal, Scheduled, @@ -85,7 +86,7 @@ public: [[nodiscard]] rpl::producer<> sendRequests() const; [[nodiscard]] rpl::producer editRequests() const; [[nodiscard]] rpl::producer<> attachRequests() const; - [[nodiscard]] rpl::producer> fileChosen() const; + [[nodiscard]] rpl::producer fileChosen() const; [[nodiscard]] rpl::producer> photoChosen() const; [[nodiscard]] rpl::producer scrollRequests() const; [[nodiscard]] rpl::producer> keyEvents() const; @@ -154,7 +155,7 @@ private: const std::unique_ptr _header; rpl::event_stream<> _cancelRequests; - rpl::event_stream> _fileChosen; + rpl::event_stream _fileChosen; rpl::event_stream> _photoChosen; rpl::event_stream _inlineResultChosen; diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index 06bfcdb603..021a3d5165 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -199,8 +199,9 @@ void ScheduledWidget::setupComposeControls() { }, lifetime()); _composeControls->fileChosen( - ) | rpl::start_with_next([=](not_null document) { - sendExistingDocument(document); + ) | rpl::start_with_next([=]( + ChatHelpers::TabbedSelector::FileChosen chosen) { + sendExistingDocument(chosen.document); }, lifetime()); _composeControls->photoChosen( diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 89cfa644e0..603557c226 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1081,7 +1081,7 @@ void MainWidget::inlineResultLoadFailed(FileLoader *loader, bool started) { } bool MainWidget::sendExistingDocument(not_null document) { - return _history->sendExistingDocument(document); + return _history->sendExistingDocument(document, Api::SendOptions()); } void MainWidget::dialogsCancelled() {