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) {

View File

@@ -14,11 +14,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Settings {
class BlockedBoxController : public PeerListController, private base::Subscriber, private MTP::Sender {
class BlockedBoxController
: public PeerListController
, private base::Subscriber
, private MTP::Sender {
public:
explicit BlockedBoxController(
not_null<Window::SessionController*> window);
Main::Session &session() const override;
void prepare() override;
void rowClicked(not_null<PeerListRow*> row) override;
void rowActionClicked(not_null<PeerListRow*> row) override;

View File

@@ -448,7 +448,9 @@ void SetupSelfDestruction(
label(),
st::settingsButton
)->addClickHandler([=] {
Ui::show(Box<SelfDestructionBox>(session->api().selfDestructValue()));
Ui::show(Box<SelfDestructionBox>(
session,
session->api().selfDestructValue()));
});
AddSkip(container);
@@ -464,8 +466,8 @@ void SetupSessionsList(
container,
tr::lng_settings_show_sessions(),
st::settingsButton
)->addClickHandler([] {
Ui::show(Box<SessionsBox>());
)->addClickHandler([=] {
Ui::show(Box<SessionsBox>(&controller->session()));
});
AddSkip(container, st::settingsPrivacySecurityPadding);
AddDividerText(container, tr::lng_settings_sessions_about());