From 1f8f462461a9f374c0d4a28b64623012d2201a4c Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 3 Mar 2022 10:42:49 +0300 Subject: [PATCH] Removed Ui::show from EditLinkedChatBox. --- .../boxes/peers/edit_linked_chat_box.cpp | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp index 95761ffbd..b2d675d3e 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp @@ -19,8 +19,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/boxes/confirm_box.h" #include "boxes/add_contact_box.h" #include "apiwrap.h" -#include "facades.h" #include "main/main_session.h" +#include "window/window_session_controller.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_info.h" @@ -35,7 +35,8 @@ public: not_null channel, ChannelData *chat, const std::vector> &chats, - Fn callback); + Fn callback, + Fn)> showHistoryCallback); Main::Session &session() const override; void prepare() override; @@ -50,20 +51,24 @@ private: ChannelData *_chat = nullptr; std::vector> _chats; Fn _callback; + Fn)> _showHistoryCallback; ChannelData *_waitForFull = nullptr; + rpl::event_stream> _showHistoryRequest; }; Controller::Controller( not_null channel, ChannelData *chat, const std::vector> &chats, - Fn callback) + Fn callback, + Fn)> showHistoryCallback) : _channel(channel) , _chat(chat) , _chats(std::move(chats)) -, _callback(std::move(callback)) { +, _callback(std::move(callback)) +, _showHistoryCallback(std::move(showHistoryCallback)) { channel->session().changes().peerUpdates( Data::PeerUpdate::Flag::FullInfo ) | rpl::filter([=](const Data::PeerUpdate &update) { @@ -109,7 +114,7 @@ void Controller::prepare() { void Controller::rowClicked(not_null row) { if (_chat != nullptr) { - Ui::showPeerHistory(_chat, ShowAtUnreadMsgId); + _showHistoryCallback(_chat); return; } const auto peer = row->peer(); @@ -152,7 +157,7 @@ void Controller::choose(not_null chat) { const auto onstack = _callback; onstack(chat); }; - Ui::show( + delegate()->peerListShowBox( Ui::MakeConfirmBox({ .text = text, .confirmed = sure, @@ -185,7 +190,7 @@ void Controller::choose(not_null chat) { }; chat->session().api().migrateChat(chat, crl::guard(this, done)); }; - Ui::show( + delegate()->peerListShowBox( Ui::MakeConfirmBox({ .text = text, .confirmed = sure, @@ -248,7 +253,7 @@ object_ptr SetupCreateGroup( st::infoCreateLinkedChatButton); result->addClickHandler([=] { const auto guarded = crl::guard(parent, callback); - Ui::show( + Window::Show(navigation).showBox( Box( navigation, GroupInfoBox::Type::Megagroup, @@ -312,11 +317,18 @@ object_ptr EditLinkedChatBox( : tr::lng_manage_linked_channel()); box->addButton(tr::lng_close(), [=] { box->closeBox(); }); }; + auto showHistoryCallback = [=](not_null peer) { + navigation->showPeerHistory( + peer, + Window::SectionShow::Way::ClearStack, + ShowAtUnreadMsgId); + }; auto controller = std::make_unique( channel, chat, std::move(chats), - std::move(callback)); + std::move(callback), + std::move(showHistoryCallback)); return Box(std::move(controller), init); }