diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 67663c16f..7df89882f 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -474,7 +474,7 @@ void PeerListBox::addSelectItem( void PeerListBox::addSelectItem( uint64 itemId, const QString &text, - Ui::MultiSelect::PaintRoundImage paintUserpic, + PaintRoundImageCallback paintUserpic, anim::type animated) { if (!_select) { createMultiSelect(); @@ -549,6 +549,10 @@ rpl::producer PeerListBox::multiSelectHeightValue() const { return _select ? _select->heightValue() : rpl::single(0); } +rpl::producer<> PeerListBox::noSearchSubmits() const { + return content()->noSearchSubmits(); +} + PeerListRow::PeerListRow(not_null peer) : PeerListRow(peer, peer->id.value) { } @@ -2189,6 +2193,9 @@ bool PeerListContent::submitted() { _controller->rowClicked(row); return true; } + } else { + _noSearchSubmits.fire({}); + return true; } return false; } diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index 3c0dade70..05d1fddec 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -712,7 +712,7 @@ public: update(); } - std::unique_ptr saveState() const; + [[nodiscard]] std::unique_ptr saveState() const; void restoreState(std::unique_ptr state); void showRowMenu( @@ -720,10 +720,14 @@ public: bool highlightRow, Fn)> destroyed); - auto scrollToRequests() const { + [[nodiscard]] auto scrollToRequests() const { return _scrollToRequests.events(); } + [[nodiscard]] auto noSearchSubmits() const { + return _noSearchSubmits.events(); + } + ~PeerListContent(); protected: @@ -890,6 +894,8 @@ private: object_ptr _searchLoading = { nullptr }; object_ptr _loadingAnimation = { nullptr }; + rpl::event_stream<> _noSearchSubmits; + std::vector> _searchRows; base::Timer _repaintByStatus; base::unique_qptr _contextMenu; @@ -1106,6 +1112,7 @@ public: [[nodiscard]] std::vector collectSelectedIds(); [[nodiscard]] std::vector> collectSelectedRows(); [[nodiscard]] rpl::producer multiSelectHeightValue() const; + [[nodiscard]] rpl::producer<> noSearchSubmits() const; void peerListSetTitle(rpl::producer title) override { setTitle(std::move(title)); diff --git a/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp b/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp index 8b0429c28..5ceebc210 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp @@ -917,6 +917,7 @@ void DraftOptionsBox( struct AuthorSelector { object_ptr content = { nullptr }; Fn overrideKey; + Fn activate; }; [[nodiscard]] AuthorSelector AuthorRowSelector( not_null session, @@ -975,12 +976,15 @@ struct AuthorSelector { tr::lng_reply_in_author())); Ui::AddSkip(container); + const auto activate = [=] { + chosen(from->owner().history(from)); + }; const auto delegate = container->lifetime().make_state< PeerListContentDelegateSimple >(); const auto controller = container->lifetime().make_state< AuthorController - >(from, [=] { chosen(from->owner().history(from)); }); + >(from, activate); controller->setStyleOverrides(&st::peerListSingleRow); const auto content = container->add(object_ptr( container, @@ -1021,6 +1025,7 @@ struct AuthorSelector { return { .content = std::move(result), .overrideKey = overrideKey, + .activate = activate, }; } @@ -1051,6 +1056,12 @@ void ShowReplyToChatBox( } } + void noSearchSubmit() { + if (const auto onstack = _authorRow.activate) { + onstack(); + } + } + [[nodiscard]] rpl::producer singleChosen() const { return _singleChosen.events(); } @@ -1094,6 +1105,10 @@ void ShowReplyToChatBox( auto box = Box(std::move(controller), [=]( not_null box) { box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); + + box->noSearchSubmits() | rpl::start_with_next([=] { + controllerRaw->noSearchSubmit(); + }, box->lifetime()); }); const auto boxRaw = box.data(); show->show(std::move(box));