Removed Ui::show from ShowSearchFromBox.

This commit is contained in:
23rd 2022-03-21 15:44:37 +03:00 committed by John Preston
parent 38abfacd88
commit 89ab23e70f
3 changed files with 14 additions and 7 deletions

View file

@ -17,7 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Dialogs { namespace Dialogs {
void ShowSearchFromBox( object_ptr<Ui::BoxContent> SearchFromBox(
not_null<PeerData*> peer, not_null<PeerData*> peer,
Fn<void(not_null<PeerData*>)> callback, Fn<void(not_null<PeerData*>)> callback,
Fn<void()> closedCallback) { Fn<void()> closedCallback) {
@ -34,15 +34,19 @@ void ShowSearchFromBox(
}; };
if (auto controller = createController()) { if (auto controller = createController()) {
auto subscription = std::make_shared<rpl::lifetime>(); auto subscription = std::make_shared<rpl::lifetime>();
auto box = Ui::show(Box<PeerListBox>(std::move(controller), [subscription](not_null<PeerListBox*> box) { auto box = Box<PeerListBox>(
box->addButton(tr::lng_cancel(), [box, subscription] { std::move(controller),
box->closeBox(); [subscription](not_null<PeerListBox*> box) {
box->addButton(tr::lng_cancel(), [box, subscription] {
box->closeBox();
});
}); });
}), Ui::LayerOption::KeepOther);
box->boxClosing() | rpl::start_with_next( box->boxClosing() | rpl::start_with_next(
std::move(closedCallback), std::move(closedCallback),
*subscription); *subscription);
return box;
} }
return nullptr;
} }
SearchFromController::SearchFromController( SearchFromController::SearchFromController(

View file

@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Dialogs { namespace Dialogs {
void ShowSearchFromBox( object_ptr<Ui::BoxContent> SearchFromBox(
not_null<PeerData*> peer, not_null<PeerData*> peer,
Fn<void(not_null<PeerData*>)> callback, Fn<void(not_null<PeerData*>)> callback,
Fn<void()> closedCallback); Fn<void()> closedCallback);

View file

@ -1537,7 +1537,7 @@ void Widget::showCalendar() {
void Widget::showSearchFrom() { void Widget::showSearchFrom() {
if (const auto peer = _searchInChat.peer()) { if (const auto peer = _searchInChat.peer()) {
const auto chat = _searchInChat; const auto chat = _searchInChat;
ShowSearchFromBox( auto box = SearchFromBox(
peer, peer,
crl::guard(this, [=](not_null<PeerData*> from) { crl::guard(this, [=](not_null<PeerData*> from) {
Ui::hideLayer(); Ui::hideLayer();
@ -1545,6 +1545,9 @@ void Widget::showSearchFrom() {
applyFilterUpdate(true); applyFilterUpdate(true);
}), }),
crl::guard(this, [=] { _filter->setFocus(); })); crl::guard(this, [=] { _filter->setFocus(); }));
if (box) {
Window::Show(controller()).showBox(std::move(box));
}
} }
} }