2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Pass SessionNavigation to some boxes.

This commit is contained in:
John Preston
2019-07-25 20:55:11 +02:00
parent 137fa0378c
commit bacaf805b5
54 changed files with 601 additions and 233 deletions

View File

@@ -46,6 +46,10 @@ class BlockUserBoxController
: public ChatsListBoxController
, private base::Subscriber {
public:
explicit BlockUserBoxController(
not_null<Window::SessionNavigation*> navigation);
Main::Session &session() const override;
void rowClicked(not_null<PeerListRow*> row) override;
void setBlockUserCallback(Fn<void(not_null<UserData*> user)> callback) {
@@ -63,10 +67,21 @@ protected:
private:
void updateIsBlocked(not_null<PeerListRow*> row, UserData *user) const;
const not_null<Window::SessionNavigation*> _navigation;
Fn<void(not_null<UserData*> user)> _blockUserCallback;
};
BlockUserBoxController::BlockUserBoxController(
not_null<Window::SessionNavigation*> navigation)
: ChatsListBoxController(navigation)
, _navigation(navigation) {
}
Main::Session &BlockUserBoxController::session() const {
return _navigation->session();
}
void BlockUserBoxController::prepareViewHook() {
delegate()->peerListSetTitle(tr::lng_blocked_list_add_title());
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::UserIsBlocked, [this](const Notify::PeerUpdate &update) {
@@ -160,6 +175,10 @@ BlockedBoxController::BlockedBoxController(
: _window(window) {
}
Main::Session &BlockedBoxController::session() const {
return _window->session();
}
void BlockedBoxController::prepare() {
delegate()->peerListSetTitle(tr::lng_blocked_list_title());
setDescriptionText(tr::lng_contacts_loading(tr::now));
@@ -262,7 +281,7 @@ void BlockedBoxController::handleBlockedEvent(not_null<UserData*> user) {
void BlockedBoxController::BlockNewUser(
not_null<Window::SessionController*> window) {
auto controller = std::make_unique<BlockUserBoxController>();
auto controller = std::make_unique<BlockUserBoxController>(window);
auto initBox = [=, controller = controller.get()](
not_null<PeerListBox*> box) {
controller->setBlockUserCallback([=](not_null<UserData*> user) {