diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index c50dbe9e7..e470c651e 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -4346,6 +4346,9 @@ void HistoryInner::refreshAboutView(bool force) { _aboutView->refreshRequests() | rpl::start_with_next([=] { updateBotInfo(); }, _aboutView->lifetime()); + _aboutView->sendIntroSticker() | rpl::start_to_stream( + _sendIntroSticker, + _aboutView->lifetime()); } }; if (const auto user = _peer->asUser()) { @@ -4777,6 +4780,11 @@ ClickContext HistoryInner::prepareClickContext( }; } +auto HistoryInner::sendIntroSticker() const +-> rpl::producer> { + return _sendIntroSticker.events(); +} + auto HistoryInner::DelegateMixin() -> std::unique_ptr { return std::make_unique(); diff --git a/Telegram/SourceFiles/history/history_inner_widget.h b/Telegram/SourceFiles/history/history_inner_widget.h index 6b4d350c5..1288f6e7b 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.h +++ b/Telegram/SourceFiles/history/history_inner_widget.h @@ -221,6 +221,9 @@ public: Qt::MouseButton button, FullMsgId itemId) const; + [[nodiscard]] auto sendIntroSticker() const + -> rpl::producer>; + [[nodiscard]] static auto DelegateMixin() -> std::unique_ptr; @@ -466,6 +469,7 @@ private: std::unique_ptr _aboutView; std::unique_ptr _emptyPainter; std::unique_ptr _translateTracker; + rpl::event_stream> _sendIntroSticker; mutable History *_curHistory = nullptr; mutable int _curBlock = 0; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index ca5be0a39..dabb93a47 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -2525,6 +2525,12 @@ void HistoryWidget::showHistory( _scroll->hide(); _list = _scroll->setOwnedWidget( object_ptr(this, _scroll, controller(), _history)); + _list->sendIntroSticker( + ) | rpl::start_with_next([=](not_null sticker) { + sendExistingDocument( + sticker, + Api::MessageToSend(prepareSendAction({}))); + }, _list->lifetime()); _list->show(); if (const auto channel = _peer->asChannel()) { diff --git a/Telegram/SourceFiles/history/view/history_view_about_view.cpp b/Telegram/SourceFiles/history/view/history_view_about_view.cpp index c1f9346b5..d2ad1b735 100644 --- a/Telegram/SourceFiles/history/view/history_view_about_view.cpp +++ b/Telegram/SourceFiles/history/view/history_view_about_view.cpp @@ -199,7 +199,8 @@ auto GenerateChatIntro( not_null parent, Element *replacing, const Data::ChatIntro &data, - Fn)> helloChosen) + Fn)> helloChosen, + Fn)> sendIntroSticker) -> Fn, Fn)>)> { @@ -243,9 +244,7 @@ auto GenerateChatIntro( } } const auto send = [=] { - Api::SendExistingDocument(Api::MessageToSend( - Api::SendAction(parent->history()) - ), sticker); + sendIntroSticker(sticker); }; return StickerInBubblePart::Data{ .sticker = sticker, @@ -598,9 +597,17 @@ void AboutView::make(Data::ChatIntro data, bool preview) { } } }; + const auto sendIntroSticker = [=](not_null sticker) { + _sendIntroSticker.fire_copy(sticker); + }; owned->overrideMedia(std::make_unique( owned.get(), - GenerateChatIntro(owned.get(), _item.get(), data, helloChosen), + GenerateChatIntro( + owned.get(), + _item.get(), + data, + helloChosen, + sendIntroSticker), HistoryView::MediaGenericDescriptor{ .maxWidth = st::chatIntroWidth, .serviceLink = std::make_shared(handler), @@ -613,6 +620,10 @@ void AboutView::make(Data::ChatIntro data, bool preview) { setItem(std::move(owned), data.sticker); } +rpl::producer> AboutView::sendIntroSticker() const { + return _sendIntroSticker.events(); +} + rpl::producer<> AboutView::refreshRequests() const { return _refreshRequests.events(); } diff --git a/Telegram/SourceFiles/history/view/history_view_about_view.h b/Telegram/SourceFiles/history/view/history_view_about_view.h index b52d7edf0..b2c8d3cbb 100644 --- a/Telegram/SourceFiles/history/view/history_view_about_view.h +++ b/Telegram/SourceFiles/history/view/history_view_about_view.h @@ -30,6 +30,8 @@ public: void make(Data::ChatIntro data, bool preview = false); + [[nodiscard]] auto sendIntroSticker() const + -> rpl::producer>; [[nodiscard]] rpl::producer<> refreshRequests() const; [[nodiscard]] rpl::lifetime &lifetime(); @@ -63,6 +65,8 @@ private: DocumentData *_sticker = nullptr; int _version = 0; + rpl::event_stream> _sendIntroSticker; + bool _commonGroupsStale = false; bool _commonGroupsRequested = false; std::vector> _commonGroups;