From bacaf805b52d7380063db9b51bda565c34c32ad9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 25 Jul 2019 20:55:11 +0200 Subject: [PATCH] Pass SessionNavigation to some boxes. --- .../SourceFiles/boxes/add_contact_box.cpp | 30 +++--- Telegram/SourceFiles/boxes/add_contact_box.h | 10 +- .../SourceFiles/boxes/edit_privacy_box.cpp | 14 ++- Telegram/SourceFiles/boxes/peer_list_box.cpp | 22 +++-- Telegram/SourceFiles/boxes/peer_list_box.h | 5 + .../boxes/peer_list_controllers.cpp | 93 +++++++++++++------ .../SourceFiles/boxes/peer_list_controllers.h | 37 ++++++-- .../boxes/peers/add_participants_box.cpp | 40 ++++++-- .../boxes/peers/add_participants_box.h | 23 ++++- .../boxes/peers/edit_linked_chat_box.cpp | 26 +++++- .../boxes/peers/edit_linked_chat_box.h | 6 ++ .../boxes/peers/edit_participants_box.cpp | 7 +- .../boxes/peers/edit_participants_box.h | 1 + .../boxes/peers/edit_peer_info_box.cpp | 37 ++++++-- .../boxes/peers/edit_peer_info_box.h | 10 +- Telegram/SourceFiles/boxes/rate_call_box.cpp | 13 ++- Telegram/SourceFiles/boxes/rate_call_box.h | 12 ++- .../boxes/self_destruction_box.cpp | 6 +- .../SourceFiles/boxes/self_destruction_box.h | 10 +- Telegram/SourceFiles/boxes/send_files_box.cpp | 14 +-- Telegram/SourceFiles/boxes/sessions_box.cpp | 7 +- Telegram/SourceFiles/boxes/sessions_box.h | 8 +- Telegram/SourceFiles/boxes/share_box.cpp | 80 ++++++++++------ Telegram/SourceFiles/boxes/share_box.h | 21 ++++- .../SourceFiles/boxes/sticker_set_box.cpp | 28 +++--- .../calls/calls_box_controller.cpp | 21 +++-- .../SourceFiles/calls/calls_box_controller.h | 9 ++ Telegram/SourceFiles/calls/calls_call.cpp | 2 +- .../chat_helpers/gifs_list_widget.cpp | 22 +++-- .../SourceFiles/core/local_url_handlers.cpp | 2 +- .../history/history_inner_widget.cpp | 6 +- .../SourceFiles/history/history_message.cpp | 1 + .../SourceFiles/history/history_widget.cpp | 13 +-- .../view/history_view_context_menu.cpp | 26 ++++-- .../history/view/history_view_context_menu.h | 9 +- .../history/view/history_view_list_widget.cpp | 2 +- .../info_common_groups_inner_widget.cpp | 5 + Telegram/SourceFiles/info/info_top_bar.cpp | 9 +- Telegram/SourceFiles/info/info_top_bar.h | 8 +- .../SourceFiles/info/info_wrap_widget.cpp | 2 +- .../info/media/info_media_list_widget.cpp | 1 + .../info/profile/info_profile_actions.cpp | 13 ++- .../info/profile/info_profile_members.cpp | 3 +- Telegram/SourceFiles/mainwidget.cpp | 12 ++- Telegram/SourceFiles/mainwindow.cpp | 6 +- .../media/view/media_view_overlay_widget.cpp | 5 +- .../platform/mac/main_window_mac.mm | 2 +- .../settings/settings_privacy_controllers.cpp | 21 ++++- .../settings/settings_privacy_controllers.h | 6 +- .../settings/settings_privacy_security.cpp | 8 +- .../SourceFiles/window/window_main_menu.cpp | 9 +- .../SourceFiles/window/window_peer_menu.cpp | 39 +++++--- .../SourceFiles/window/window_peer_menu.h | 10 +- .../window/window_session_controller.cpp | 2 +- 54 files changed, 601 insertions(+), 233 deletions(-) diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index 860fdc8cc..448c1fd0a 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/file_utilities.h" #include "core/application.h" #include "chat_helpers/emoji_suggestions_widget.h" +#include "window/window_session_controller.h" #include "ui/widgets/checkbox.h" #include "ui/widgets/buttons.h" #include "ui/widgets/input_fields.h" @@ -389,11 +390,11 @@ void AddContactBox::updateButtons() { GroupInfoBox::GroupInfoBox( QWidget*, - not_null session, + not_null navigation, Type type, const QString &title, Fn)> channelDone) -: _session(session) +: _navigation(navigation) , _type(type) , _initialTitle(title) , _channelDone(std::move(channelDone)) { @@ -517,7 +518,7 @@ void GroupInfoBox::createGroup( auto image = _photo->takeResultImage(); Ui::hideLayer(); - _session->api().applyUpdates(result); + _navigation->session().api().applyUpdates(result); auto success = base::make_optional(&result) | [](auto updates) -> std::optional*> { @@ -538,7 +539,8 @@ void GroupInfoBox::createGroup( : std::nullopt; } | [&](auto chats) { - return _session->data().chat(chats->front().c_chat().vid().v); + return _navigation->session().data().chat( + chats->front().c_chat().vid().v); } | [&](not_null chat) { if (!image.isNull()) { @@ -609,7 +611,7 @@ void GroupInfoBox::submit() { }; Ui::show( Box( - std::make_unique(), + std::make_unique(_navigation), std::move(initBox)), LayerOption::KeepOther); } @@ -626,7 +628,7 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio MTPInputGeoPoint(), // geo_point MTPstring() // address )).done([=](const MTPUpdates &result) { - _session->api().applyUpdates(result); + _navigation->session().api().applyUpdates(result); const auto success = base::make_optional(&result) | [](auto updates) -> std::optional*> { @@ -645,7 +647,8 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio : std::nullopt; } | [&](auto chats) { - return _session->data().channel(chats->front().c_channel().vid().v); + return _navigation->session().data().channel( + chats->front().c_channel().vid().v); } | [&](not_null channel) { auto image = _photo->takeResultImage(); @@ -669,7 +672,9 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio closeBox(); callback(argument); } else { - Ui::show(Box(_createdChannel)); + Ui::show(Box( + _navigation, + _createdChannel)); } }).send(); }; @@ -711,9 +716,11 @@ void GroupInfoBox::updateMaxHeight() { SetupChannelBox::SetupChannelBox( QWidget*, + not_null navigation, not_null channel, bool existing) -: _channel(channel) +: _navigation(navigation) +, _channel(channel) , _existing(existing) , _privacyGroup( std::make_shared>(Privacy::Public)) @@ -788,7 +795,7 @@ void SetupChannelBox::prepare() { boxClosing() | rpl::start_with_next([=] { if (!_existing) { - AddParticipantsBoxController::Start(_channel); + AddParticipantsBoxController::Start(_navigation, _channel); } }, lifetime()); @@ -1092,9 +1099,10 @@ bool SetupChannelBox::onCheckFail(const RPCError &error) { void SetupChannelBox::showRevokePublicLinkBoxForEdit() { const auto channel = _channel; const auto existing = _existing; + const auto navigation = _navigation; const auto callback = [=] { Ui::show( - Box(channel, existing), + Box(navigation, channel, existing), LayerOption::KeepOther); }; closeBox(); diff --git a/Telegram/SourceFiles/boxes/add_contact_box.h b/Telegram/SourceFiles/boxes/add_contact_box.h index 7278522e1..486b0669f 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.h +++ b/Telegram/SourceFiles/boxes/add_contact_box.h @@ -14,6 +14,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL class ConfirmBox; class PeerListBox; +namespace Window { +class SessionNavigation; +} // namespace Window + namespace Main { class Session; } // namespace Main @@ -98,7 +102,7 @@ public: }; GroupInfoBox( QWidget*, - not_null session, + not_null navigation, Type type, const QString &title = QString(), Fn)> channelDone = nullptr); @@ -118,7 +122,7 @@ private: void descriptionResized(); void updateMaxHeight(); - const not_null _session; + const not_null _navigation; Type _type = Type::Group; QString _initialTitle; @@ -138,6 +142,7 @@ class SetupChannelBox : public BoxContent, public RPCSender { public: SetupChannelBox( QWidget*, + not_null navigation, not_null channel, bool existing = false); @@ -175,6 +180,7 @@ private: void showRevokePublicLinkBoxForEdit(); + const not_null _navigation; const not_null _channel; bool _existing = false; diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp index ed6152957..7c6a0ee45 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp @@ -34,8 +34,11 @@ namespace { class PrivacyExceptionsBoxController : public ChatsListBoxController { public: PrivacyExceptionsBoxController( + not_null navigation, rpl::producer title, const std::vector> &selected); + + Main::Session &session() const override; void rowClicked(not_null row) override; std::vector> getResult() const; @@ -45,18 +48,26 @@ protected: std::unique_ptr createRow(not_null history) override; private: + not_null _navigation; rpl::producer _title; std::vector> _selected; }; PrivacyExceptionsBoxController::PrivacyExceptionsBoxController( + not_null navigation, rpl::producer title, const std::vector> &selected) -: _title(std::move(title)) +: ChatsListBoxController(navigation) +, _navigation(navigation) +, _title(std::move(title)) , _selected(selected) { } +Main::Session &PrivacyExceptionsBoxController::session() const { + return _navigation->session(); +} + void PrivacyExceptionsBoxController::prepareViewHook() { delegate()->peerListSetTitle(std::move(_title)); delegate()->peerListAddSelectedRows(_selected); @@ -132,6 +143,7 @@ void EditPrivacyBox::editExceptions( Exception exception, Fn done) { auto controller = std::make_unique( + _window, _controller->exceptionBoxTitle(exception), exceptions(exception)); auto initBox = [=, controller = controller.get()]( diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index c64eddb42..f7b2f375e 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -66,11 +66,15 @@ void PeerListBox::createMultiSelect() { ) | rpl::start_with_next( [this] { updateScrollSkips(); }, lifetime()); - _select->entity()->setSubmittedCallback([this](Qt::KeyboardModifiers) { content()->submitted(); }); - _select->entity()->setQueryChangedCallback([this](const QString &query) { searchQueryChanged(query); }); - _select->entity()->setItemRemovedCallback([this](uint64 itemId) { - if (auto peer = Auth().data().peerLoaded(itemId)) { - if (auto row = peerListFindRow(peer->id)) { + _select->entity()->setSubmittedCallback([=](Qt::KeyboardModifiers) { + content()->submitted(); + }); + _select->entity()->setQueryChangedCallback([=](const QString &query) { + searchQueryChanged(query); + }); + _select->entity()->setItemRemovedCallback([=](uint64 itemId) { + if (const auto peer = _controller->session().data().peerLoaded(itemId)) { + if (const auto row = peerListFindRow(peer->id)) { content()->changeCheckState(row, false, PeerListRow::SetStyle::Animated); update(); } @@ -336,7 +340,7 @@ auto PeerListBox::peerListCollectSelectedRows() if (!items.empty()) { result.reserve(items.size()); for (const auto itemId : items) { - result.push_back(Auth().data().peer(itemId)); + result.push_back(_controller->session().data().peer(itemId)); } } return result; @@ -574,7 +578,9 @@ PeerListContent::PeerListContent( , _st(st) , _controller(controller) , _rowHeight(_st.item.height) { - subscribe(Auth().downloaderTaskFinished(), [this] { update(); }); + subscribe(_controller->session().downloaderTaskFinished(), [=] { + update(); + }); using UpdateFlag = Notify::PeerUpdate::Flag; auto changes = UpdateFlag::NameChanged | UpdateFlag::PhotoChanged; @@ -1279,7 +1285,7 @@ void PeerListContent::loadProfilePhotos() { auto yFrom = _visibleTop; auto yTo = _visibleBottom + (_visibleBottom - _visibleTop) * PreloadHeightsCount; - Auth().downloader().clearPriorities(); + _controller->session().downloader().clearPriorities(); if (yTo < 0) return; if (yFrom < 0) yFrom = 0; diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index 0823fec5d..ceced9760 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -19,6 +19,10 @@ struct PeerList; struct PeerListItem; } // namespace style +namespace Main { +class Session; +} // namespace Main + namespace Ui { class RippleAnimation; class RoundImageCheckbox; @@ -334,6 +338,7 @@ public: virtual void prepare() = 0; virtual void rowClicked(not_null row) = 0; + virtual Main::Session &session() const = 0; virtual void rowActionClicked(not_null row) { } virtual void loadMoreRows() { diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index 83fc416ea..5d5e2ddc2 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "history/history.h" #include "dialogs/dialogs_main_list.h" +#include "window/window_session_controller.h" #include "styles/style_boxes.h" #include "styles/style_profile.h" @@ -136,7 +137,9 @@ void PeerListRowWithLink::paintAction( p.drawTextLeft(x, y, outerWidth, _action, _actionWidth); } -PeerListGlobalSearchController::PeerListGlobalSearchController() { +PeerListGlobalSearchController::PeerListGlobalSearchController( + not_null navigation) +: _navigation(navigation) { _timer.setCallback([this] { searchOnServer(); }); } @@ -185,8 +188,8 @@ void PeerListGlobalSearchController::searchDone( auto &contacts = result.c_contacts_found(); auto query = _query; if (requestId) { - Auth().data().processUsers(contacts.vusers()); - Auth().data().processChats(contacts.vchats()); + _navigation->session().data().processUsers(contacts.vusers()); + _navigation->session().data().processChats(contacts.vchats()); auto it = _queries.find(requestId); if (it != _queries.cend()) { query = it->second; @@ -196,7 +199,9 @@ void PeerListGlobalSearchController::searchDone( } const auto feedList = [&](const MTPVector &list) { for (const auto &mtpPeer : list.v) { - if (const auto peer = Auth().data().peerLoaded(peerFromMTP(mtpPeer))) { + const auto peer = _navigation->session().data().peerLoaded( + peerFromMTP(mtpPeer)); + if (peer) { delegate()->peerListSearchAddRow(peer); } } @@ -218,6 +223,12 @@ ChatsListBoxController::Row::Row(not_null history) , _history(history) { } +ChatsListBoxController::ChatsListBoxController( + not_null navigation) +: ChatsListBoxController( + std::make_unique(navigation)) { +} + ChatsListBoxController::ChatsListBoxController( std::unique_ptr searchController) : PeerListController(std::move(searchController)) { @@ -229,8 +240,8 @@ void ChatsListBoxController::prepare() { prepareViewHook(); - if (!Auth().data().chatsListLoaded()) { - Auth().data().chatsListLoadedEvents( + if (!session().data().chatsListLoaded()) { + session().data().chatsListLoadedEvents( ) | rpl::filter([=](Data::Folder *folder) { return !folder; }) | rpl::start_with_next([=] { @@ -238,12 +249,12 @@ void ChatsListBoxController::prepare() { }, lifetime()); } - Auth().data().chatsListChanges( + session().data().chatsListChanges( ) | rpl::start_with_next([=] { rebuildRows(); }, lifetime()); - Auth().data().contactsLoaded().value( + session().data().contactsLoaded().value( ) | rpl::start_with_next([=] { rebuildRows(); }, lifetime()); @@ -264,16 +275,16 @@ void ChatsListBoxController::rebuildRows() { }; auto added = 0; if (respectSavedMessagesChat()) { - if (appendRow(Auth().data().history(Auth().user()))) { + if (appendRow(session().data().history(session().user()))) { ++added; } } - added += appendList(Auth().data().chatsList()->indexed()); + added += appendList(session().data().chatsList()->indexed()); const auto id = Data::Folder::kId; - if (const auto folder = Auth().data().folderLoaded(id)) { + if (const auto folder = session().data().folderLoaded(id)) { added += appendList(folder->chatsList()->indexed()); } - added += appendList(Auth().data().contactsNoChatsList()); + added += appendList(session().data().contactsNoChatsList()); if (!wasEmpty && added > 0) { // Place dialogs list before contactsNoDialogs list. delegate()->peerListPartitionRows([](const PeerListRow &a) { @@ -294,8 +305,8 @@ void ChatsListBoxController::checkForEmptyRows() { if (delegate()->peerListFullRowsCount()) { setDescriptionText(QString()); } else { - const auto loaded = Auth().data().contactsLoaded().current() - && Auth().data().chatsListLoaded(); + const auto loaded = session().data().contactsLoaded().current() + && session().data().chatsListLoaded(); setDescriptionText(loaded ? emptyBoxText() : tr::lng_contacts_loading(tr::now)); } } @@ -321,8 +332,21 @@ bool ChatsListBoxController::appendRow(not_null history) { } ContactsBoxController::ContactsBoxController( + not_null navigation) +: PeerListController( + std::make_unique(navigation)) +, _navigation(navigation) { +} + +ContactsBoxController::ContactsBoxController( + not_null navigation, std::unique_ptr searchController) -: PeerListController(std::move(searchController)) { +: PeerListController(std::move(searchController)) +, _navigation(navigation) { +} + +Main::Session &ContactsBoxController::session() const { + return _navigation->session(); } void ContactsBoxController::prepare() { @@ -332,7 +356,7 @@ void ContactsBoxController::prepare() { prepareViewHook(); - Auth().data().contactsLoaded().value( + session().data().contactsLoaded().value( ) | rpl::start_with_next([=] { rebuildRows(); }, lifetime()); @@ -352,7 +376,7 @@ void ContactsBoxController::rebuildRows() { } return count; }; - appendList(Auth().data().contactsList()); + appendList(session().data().contactsList()); checkForEmptyRows(); delegate()->peerListRefreshRows(); } @@ -360,7 +384,7 @@ void ContactsBoxController::rebuildRows() { void ContactsBoxController::checkForEmptyRows() { setDescriptionText(delegate()->peerListFullRowsCount() ? QString() - : Auth().data().contactsLoaded().current() + : session().data().contactsLoaded().current() ? tr::lng_contacts_not_found(tr::now) : tr::lng_contacts_loading(tr::now)); } @@ -393,20 +417,30 @@ std::unique_ptr ContactsBoxController::createRow(not_null(user); } -void AddBotToGroupBoxController::Start(not_null bot) { +void AddBotToGroupBoxController::Start( + not_null navigation, + not_null bot) { auto initBox = [=](not_null box) { box->addButton(tr::lng_cancel(), [box] { box->closeBox(); }); }; - Ui::show(Box(std::make_unique(bot), std::move(initBox))); + Ui::show(Box( + std::make_unique(navigation, bot), + std::move(initBox))); } -AddBotToGroupBoxController::AddBotToGroupBoxController(not_null bot) +AddBotToGroupBoxController::AddBotToGroupBoxController( + not_null navigation, + not_null bot) : ChatsListBoxController(SharingBotGame(bot) - ? std::make_unique() + ? std::make_unique(navigation) : nullptr) , _bot(bot) { } +Main::Session &AddBotToGroupBoxController::session() const { + return _bot->session(); +} + void AddBotToGroupBoxController::rowClicked(not_null row) { if (sharingBotGame()) { shareBotGame(row->peer()); @@ -483,7 +517,7 @@ bool AddBotToGroupBoxController::sharingBotGame() const { } QString AddBotToGroupBoxController::emptyBoxText() const { - return !Auth().data().chatsListLoaded() + return !session().data().chatsListLoaded() ? tr::lng_contacts_loading(tr::now) : sharingBotGame() ? tr::lng_bot_no_chats(tr::now) @@ -491,7 +525,7 @@ QString AddBotToGroupBoxController::emptyBoxText() const { } QString AddBotToGroupBoxController::noResultsText() const { - return !Auth().data().chatsListLoaded() + return !session().data().chatsListLoaded() ? tr::lng_contacts_loading(tr::now) : sharingBotGame() ? tr::lng_bot_chats_not_found(tr::now) @@ -507,7 +541,7 @@ void AddBotToGroupBoxController::prepareViewHook() { ? tr::lng_bot_choose_chat() : tr::lng_bot_choose_group()); updateLabels(); - Auth().data().chatsListLoadedEvents( + session().data().chatsListLoadedEvents( ) | rpl::filter([=](Data::Folder *folder) { return !folder; }) | rpl::start_with_next([=] { @@ -516,8 +550,15 @@ void AddBotToGroupBoxController::prepareViewHook() { } ChooseRecipientBoxController::ChooseRecipientBoxController( + not_null navigation, FnMut)> callback) -: _callback(std::move(callback)) { +: ChatsListBoxController(navigation) +, _navigation(navigation) +, _callback(std::move(callback)) { +} + +Main::Session &ChooseRecipientBoxController::session() const { + return _navigation->session(); } void ChooseRecipientBoxController::prepareViewHook() { diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.h b/Telegram/SourceFiles/boxes/peer_list_controllers.h index 6ed67b08f..3682d1311 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.h +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.h @@ -28,6 +28,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL // //}; +namespace Window { +class SessionNavigation; +} // namespace Window + class PeerListRowWithLink : public PeerListRow { public: using PeerListRow::PeerListRow; @@ -53,9 +57,12 @@ private: }; -class PeerListGlobalSearchController : public PeerListSearchController, private MTP::Sender { +class PeerListGlobalSearchController + : public PeerListSearchController + , private MTP::Sender { public: - PeerListGlobalSearchController(); + PeerListGlobalSearchController( + not_null navigation); void searchQuery(const QString &query) override; bool isLoading() override; @@ -68,6 +75,7 @@ private: void searchOnServer(); void searchDone(const MTPcontacts_Found &result, mtpRequestId requestId); + const not_null _navigation; base::Timer _timer; QString _query; mtpRequestId _requestId = 0; @@ -78,9 +86,9 @@ private: class ChatsListBoxController : public PeerListController { public: + ChatsListBoxController(not_null navigation); ChatsListBoxController( - std::unique_ptr searchController - = std::make_unique()); + std::unique_ptr searchController); void prepare() override final; std::unique_ptr createSearchRow(not_null peer) override final; @@ -114,9 +122,12 @@ private: class ContactsBoxController : public PeerListController { public: ContactsBoxController( - std::unique_ptr searchController - = std::make_unique()); + not_null navigation); + ContactsBoxController( + not_null navigation, + std::unique_ptr searchController); + Main::Session &session() const override; void prepare() override final; std::unique_ptr createSearchRow(not_null peer) override final; void rowClicked(not_null row) override; @@ -133,16 +144,23 @@ private: void checkForEmptyRows(); bool appendRow(not_null user); + const not_null _navigation; + }; class AddBotToGroupBoxController : public ChatsListBoxController , public base::has_weak_ptr { public: - static void Start(not_null bot); + static void Start( + not_null navigation, + not_null bot); - AddBotToGroupBoxController(not_null bot); + AddBotToGroupBoxController( + not_null navigation, + not_null bot); + Main::Session &session() const override; void rowClicked(not_null row) override; protected: @@ -171,8 +189,10 @@ class ChooseRecipientBoxController , public base::has_weak_ptr { public: ChooseRecipientBoxController( + not_null navigation, FnMut)> callback); + Main::Session &session() const override; void rowClicked(not_null row) override; bool respectSavedMessagesChat() const override { @@ -185,6 +205,7 @@ protected: not_null history) override; private: + const not_null _navigation; FnMut)> _callback; }; diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp index ce2f0a6b0..dfea07f62 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp @@ -47,20 +47,29 @@ base::flat_set> GetAlreadyInFromPeer(PeerData *peer) { } // namespace -AddParticipantsBoxController::AddParticipantsBoxController() +AddParticipantsBoxController::AddParticipantsBoxController( + not_null navigation) : ContactsBoxController( - std::make_unique()) { + navigation, + std::make_unique(navigation)) { } AddParticipantsBoxController::AddParticipantsBoxController( + not_null navigation, not_null peer) -: AddParticipantsBoxController(peer, GetAlreadyInFromPeer(peer)) { +: AddParticipantsBoxController( + navigation, + peer, + GetAlreadyInFromPeer(peer)) { } AddParticipantsBoxController::AddParticipantsBoxController( + not_null navigation, not_null peer, base::flat_set> &&alreadyIn) -: ContactsBoxController(std::make_unique()) +: ContactsBoxController( + navigation, + std::make_unique(navigation)) , _peer(peer) , _alreadyIn(std::move(alreadyIn)) { subscribeToMigration(); @@ -180,8 +189,12 @@ bool AddParticipantsBoxController::inviteSelectedUsers( return true; } -void AddParticipantsBoxController::Start(not_null chat) { - auto controller = std::make_unique(chat); +void AddParticipantsBoxController::Start( + not_null navigation, + not_null chat) { + auto controller = std::make_unique( + navigation, + chat); const auto weak = controller.get(); auto initBox = [=](not_null box) { box->addButton(tr::lng_participant_invite(), [=] { @@ -199,10 +212,12 @@ void AddParticipantsBoxController::Start(not_null chat) { } void AddParticipantsBoxController::Start( + not_null navigation, not_null channel, base::flat_set> &&alreadyIn, bool justCreated) { auto controller = std::make_unique( + navigation, channel, std::move(alreadyIn)); const auto weak = controller.get(); @@ -238,13 +253,16 @@ void AddParticipantsBoxController::Start( } void AddParticipantsBoxController::Start( + not_null navigation, not_null channel, base::flat_set> &&alreadyIn) { - Start(channel, std::move(alreadyIn), false); + Start(navigation, channel, std::move(alreadyIn), false); } -void AddParticipantsBoxController::Start(not_null channel) { - Start(channel, {}, true); +void AddParticipantsBoxController::Start( + not_null navigation, + not_null channel) { + Start(navigation, channel, {}, true); } AddSpecialBoxController::AddSpecialBoxController( @@ -263,6 +281,10 @@ AddSpecialBoxController::AddSpecialBoxController( subscribeToMigration(); } +Main::Session &AddSpecialBoxController::session() const { + return _peer->session(); +} + void AddSpecialBoxController::subscribeToMigration() { SubscribeToMigration( _peer, diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.h b/Telegram/SourceFiles/boxes/peers/add_participants_box.h index 6848685dc..deef59d01 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.h +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.h @@ -10,17 +10,30 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/peer_list_controllers.h" #include "boxes/peers/edit_participants_box.h" +namespace Window { +class SessionNavigation; +} // namespace Window + class AddParticipantsBoxController : public ContactsBoxController { public: - static void Start(not_null chat); - static void Start(not_null channel); static void Start( + not_null navigation, + not_null chat); + static void Start( + not_null navigation, + not_null channel); + static void Start( + not_null navigation, not_null channel, base::flat_set> &&alreadyIn); - AddParticipantsBoxController(); - AddParticipantsBoxController(not_null peer); + explicit AddParticipantsBoxController( + not_null navigation); AddParticipantsBoxController( + not_null navigation, + not_null peer); + AddParticipantsBoxController( + not_null navigation, not_null peer, base::flat_set> &&alreadyIn); @@ -34,6 +47,7 @@ protected: private: static void Start( + not_null navigation, not_null channel, base::flat_set> &&alreadyIn, bool justCreated); @@ -73,6 +87,7 @@ public: AdminDoneCallback adminDoneCallback, BannedDoneCallback bannedDoneCallback); + Main::Session &session() const override; void prepare() override; void rowClicked(not_null row) override; void loadMoreRows() override; diff --git a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp index 6ea8e2228..e4e41b661 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp @@ -34,6 +34,7 @@ public: const std::vector> &chats, Fn callback); + Main::Session &session() const override; void prepare() override; void rowClicked(not_null row) override; int contentWidth() const override; @@ -69,6 +70,10 @@ Controller::Controller( }, lifetime()); } +Main::Session &Controller::session() const { + return _channel->session(); +} + int Controller::contentWidth() const { return st::boxWidth; } @@ -232,6 +237,7 @@ object_ptr SetupFooter( object_ptr SetupCreateGroup( not_null parent, + not_null navigation, not_null channel, Fn callback) { Expects(channel->isBroadcast()); @@ -245,7 +251,7 @@ object_ptr SetupCreateGroup( const auto guarded = crl::guard(parent, callback); Ui::show( Box( - &channel->session(), + navigation, GroupInfoBox::Type::Megagroup, channel->name + " Chat", guarded), @@ -271,6 +277,7 @@ object_ptr SetupUnlink( } object_ptr EditLinkedChatBox( + not_null navigation, not_null channel, ChannelData *chat, std::vector> &&chats, @@ -284,7 +291,11 @@ object_ptr EditLinkedChatBox( SetupAbout(above, channel, chat), st::linkedChatAboutPadding); if (!chat) { - above->add(SetupCreateGroup(above, channel, callback)); + above->add(SetupCreateGroup( + above, + navigation, + channel, + callback)); } box->peerListSetAboveWidget(std::move(above)); @@ -313,10 +324,12 @@ object_ptr EditLinkedChatBox( } // namespace object_ptr EditLinkedChatBox( + not_null navigation, not_null channel, std::vector> &&chats, Fn callback) { return EditLinkedChatBox( + navigation, channel, nullptr, std::move(chats), @@ -325,9 +338,16 @@ object_ptr EditLinkedChatBox( } object_ptr EditLinkedChatBox( + not_null navigation, not_null channel, not_null chat, bool canEdit, Fn callback) { - return EditLinkedChatBox(channel, chat, {}, canEdit, callback); + return EditLinkedChatBox( + navigation, + channel, + chat, + {}, + canEdit, + callback); } diff --git a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h index 7ecd70f61..e40864935 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h @@ -9,13 +9,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/abstract_box.h" +namespace Window { +class SessionNavigation; +} // namespace Window + object_ptr EditLinkedChatBox( + not_null navigation, not_null channel, not_null chat, bool canEdit, Fn callback); object_ptr EditLinkedChatBox( + not_null navigation, not_null channel, std::vector> &&chats, Fn callback); diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 5db743d7b..20834b6c7 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -754,6 +754,10 @@ ParticipantsBoxController::ParticipantsBoxController( } } +Main::Session &ParticipantsBoxController::session() const { + return _peer->session(); +} + void ParticipantsBoxController::setupListChangeViewers() { const auto channel = _peer->asChannel(); if (!channel || !channel->isMegagroup()) { @@ -908,7 +912,7 @@ void ParticipantsBoxController::addNewParticipants() { const auto chat = _peer->asChat(); const auto channel = _peer->asChannel(); if (chat) { - AddParticipantsBoxController::Start(chat); + AddParticipantsBoxController::Start(_navigation, chat); } else if (channel->isMegagroup() || channel->membersCount() < Global::ChatSizeMax()) { const auto count = delegate()->peerListFullRowsCount(); @@ -919,6 +923,7 @@ void ParticipantsBoxController::addNewParticipants() { delegate()->peerListRowAt(i)->peer()->asUser()); } AddParticipantsBoxController::Start( + _navigation, channel, { already.begin(), already.end() }); } else { diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.h b/Telegram/SourceFiles/boxes/peers/edit_participants_box.h index 859c86459..bf6772502 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.h @@ -149,6 +149,7 @@ public: not_null peer, Role role); + Main::Session &session() const override; void prepare() override; void rowClicked(not_null row) override; void rowActionClicked(not_null row) override; diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 858525bc3..92e1de7b2 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -243,6 +243,7 @@ class Controller , private MTP::Sender { public: Controller( + not_null navigation, not_null box, not_null peer); @@ -328,9 +329,10 @@ private: std::optional _usernameSavedValue; std::optional _signaturesSavedValue; - not_null _box; + const not_null _navigation; + const not_null _box; not_null _peer; - bool _isGroup = false; + const bool _isGroup = false; base::unique_qptr _wrap; Controls _controls; @@ -348,18 +350,20 @@ private: }; Controller::Controller( + not_null navigation, not_null box, not_null peer) -: _box(box) +: _navigation(navigation) +, _box(box) , _peer(peer) , _isGroup(_peer->isChat() || _peer->isMegagroup()) { _box->setTitle(_isGroup ? tr::lng_edit_group() : tr::lng_edit_channel_title()); - _box->addButton(tr::lng_settings_save(), [this] { + _box->addButton(tr::lng_settings_save(), [=] { save(); }); - _box->addButton(tr::lng_cancel(), [this] { + _box->addButton(tr::lng_cancel(), [=] { _box->closeBox(); }); subscribeToMigration(); @@ -621,7 +625,12 @@ void Controller::showEditLinkedChatBox() { if (const auto chat = *_linkedChatSavedValue) { *box = Ui::show( - EditLinkedChatBox(channel, chat, canEdit, callback), + EditLinkedChatBox( + _navigation, + channel, + chat, + canEdit, + callback), LayerOption::KeepOther); return; } else if (!canEdit || _linkedChatsRequestId) { @@ -644,7 +653,11 @@ void Controller::showEditLinkedChatBox() { chats.emplace_back(_peer->owner().processChat(item)); } *box = Ui::show( - EditLinkedChatBox(channel, std::move(chats), callback), + EditLinkedChatBox( + _navigation, + channel, + std::move(chats), + callback), LayerOption::KeepOther); }).fail([=](const RPCError &error) { _linkedChatsRequestId = 0; @@ -1438,12 +1451,18 @@ void Controller::deleteChannel() { EditPeerInfoBox::EditPeerInfoBox( QWidget*, + not_null navigation, not_null peer) -: _peer(peer->migrateToOrMe()) { +: _navigation(navigation) +, _peer(peer->migrateToOrMe()) { } void EditPeerInfoBox::prepare() { - const auto controller = Ui::CreateChild(this, this, _peer); + const auto controller = Ui::CreateChild( + this, + _navigation, + this, + _peer); _focusRequests.events( ) | rpl::start_with_next( [=] { controller->setFocus(); }, diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.h b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.h index c2a1e2ac1..2346277ed 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.h @@ -14,6 +14,10 @@ namespace style { struct InfoProfileCountButton; } // namespace style +namespace Window { +class SessionNavigation; +} // namespace Window + namespace Ui { class VerticalLayout; } // namespace Ui @@ -26,7 +30,10 @@ class Button; class EditPeerInfoBox : public BoxContent { public: - EditPeerInfoBox(QWidget*, not_null peer); + EditPeerInfoBox( + QWidget*, + not_null navigation, + not_null peer); void setInnerFocus() override { _focusRequests.fire({}); @@ -47,6 +54,7 @@ protected: private: rpl::event_stream<> _focusRequests; + not_null _navigation; not_null _peer; }; diff --git a/Telegram/SourceFiles/boxes/rate_call_box.cpp b/Telegram/SourceFiles/boxes/rate_call_box.cpp index dd269168b..30e7371b1 100644 --- a/Telegram/SourceFiles/boxes/rate_call_box.cpp +++ b/Telegram/SourceFiles/boxes/rate_call_box.cpp @@ -25,8 +25,13 @@ constexpr auto kRateCallCommentLengthMax = 200; } // namespace -RateCallBox::RateCallBox(QWidget*, uint64 callId, uint64 callAccessHash) -: _callId(callId) +RateCallBox::RateCallBox( + QWidget*, + not_null session, + uint64 callId, + uint64 callAccessHash) +: _session(session) +, _callId(callId) , _callAccessHash(callAccessHash) { } @@ -35,7 +40,7 @@ void RateCallBox::prepare() { addButton(tr::lng_cancel(), [this] { closeBox(); }); for (auto i = 0; i < kMaxRating; ++i) { - _stars.push_back(object_ptr(this, st::callRatingStar)); + _stars.emplace_back(this, st::callRatingStar); _stars.back()->setClickedCallback([this, value = i + 1] { ratingChanged(value); }); _stars.back()->show(); } @@ -121,7 +126,7 @@ void RateCallBox::send() { MTP_int(_rating), MTP_string(comment) )).done([=](const MTPUpdates &updates) { - Auth().api().applyUpdates(updates); + _session->api().applyUpdates(updates); closeBox(); }).fail([=](const RPCError &error) { closeBox(); }).send(); } diff --git a/Telegram/SourceFiles/boxes/rate_call_box.h b/Telegram/SourceFiles/boxes/rate_call_box.h index 6eeeee7f7..641afe177 100644 --- a/Telegram/SourceFiles/boxes/rate_call_box.h +++ b/Telegram/SourceFiles/boxes/rate_call_box.h @@ -16,9 +16,17 @@ class FlatLabel; class IconButton; } // namespace Ui +namespace Main { +class Session; +} // namespace Main + class RateCallBox : public BoxContent, private MTP::Sender { public: - RateCallBox(QWidget*, uint64 callId, uint64 callAccessHash); + RateCallBox( + QWidget*, + not_null session, + uint64 callId, + uint64 callAccessHash); protected: void prepare() override; @@ -32,6 +40,8 @@ private: void send(); void commentResized(); + const not_null _session; + uint64 _callId = 0; uint64 _callAccessHash = 0; int _rating = 0; diff --git a/Telegram/SourceFiles/boxes/self_destruction_box.cpp b/Telegram/SourceFiles/boxes/self_destruction_box.cpp index 208d94a04..04b02d49d 100644 --- a/Telegram/SourceFiles/boxes/self_destruction_box.cpp +++ b/Telegram/SourceFiles/boxes/self_destruction_box.cpp @@ -16,8 +16,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL SelfDestructionBox::SelfDestructionBox( QWidget*, + not_null session, rpl::producer preloaded) -: _ttlValues{ 30, 90, 180, 365 } +: _session(session) +, _ttlValues{ 30, 90, 180, 365 } , _loading( this, tr::lng_contacts_loading(tr::now), @@ -73,7 +75,7 @@ void SelfDestructionBox::showContent() { clearButtons(); addButton(tr::lng_settings_save(), [=] { - Auth().api().saveSelfDestruct(_ttlGroup->value()); + _session->api().saveSelfDestruct(_ttlGroup->value()); closeBox(); }); addButton(tr::lng_cancel(), [=] { closeBox(); }); diff --git a/Telegram/SourceFiles/boxes/self_destruction_box.h b/Telegram/SourceFiles/boxes/self_destruction_box.h index d4f995a74..f4128e821 100644 --- a/Telegram/SourceFiles/boxes/self_destruction_box.h +++ b/Telegram/SourceFiles/boxes/self_destruction_box.h @@ -16,9 +16,16 @@ class Radiobutton; class FlatLabel; } // namespace Ui +namespace Main { +class Session; +} // namespace Main + class SelfDestructionBox : public BoxContent, private MTP::Sender { public: - SelfDestructionBox(QWidget*, rpl::producer preloaded); + SelfDestructionBox( + QWidget*, + not_null session, + rpl::producer preloaded); static QString DaysLabel(int days); @@ -29,6 +36,7 @@ private: void gotCurrent(int days); void showContent(); + const not_null _session; bool _prepared = false; std::vector _ttlValues; object_ptr _description = { nullptr }; diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 1894b1e02..420103ed2 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -1497,10 +1497,10 @@ void SendFilesBox::initSendWay() { ? SendFilesWay::Album : SendFilesWay::Photos; } - const auto currentWay = Auth().settings().sendFilesWay(); - if (currentWay == SendFilesWay::Files) { - return currentWay; - } else if (currentWay == SendFilesWay::Album) { + const auto way = _controller->session().settings().sendFilesWay(); + if (way == SendFilesWay::Files) { + return way; + } else if (way == SendFilesWay::Album) { return _list.albumIsPossible ? SendFilesWay::Album : SendFilesWay::Photos; @@ -1914,7 +1914,7 @@ void SendFilesBox::send(bool ctrlShiftEnter) { const auto way = _sendWay ? _sendWay->value() : Way::Files; if (_compressConfirm == CompressConfirm::Auto) { - const auto oldWay = Auth().settings().sendFilesWay(); + const auto oldWay = _controller->session().settings().sendFilesWay(); if (way != oldWay) { // Check if the user _could_ use the old value, but didn't. if ((oldWay == Way::Album && _sendAlbum) @@ -1922,8 +1922,8 @@ void SendFilesBox::send(bool ctrlShiftEnter) { || (oldWay == Way::Files && _sendFiles) || (way == Way::Files && (_sendAlbum || _sendPhotos))) { // And in that case save it to settings. - Auth().settings().setSendFilesWay(way); - Auth().saveSettingsDelayed(); + _controller->session().settings().setSendFilesWay(way); + _controller->session().saveSettingsDelayed(); } } } diff --git a/Telegram/SourceFiles/boxes/sessions_box.cpp b/Telegram/SourceFiles/boxes/sessions_box.cpp index 40a213aba..1ff16bdb9 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.cpp +++ b/Telegram/SourceFiles/boxes/sessions_box.cpp @@ -75,8 +75,9 @@ private: }; -SessionsBox::SessionsBox(QWidget*) -: _shortPollTimer([=] { shortPollSessions(); }) { +SessionsBox::SessionsBox(QWidget*, not_null session) +: _session(session) +, _shortPollTimer([=] { shortPollSessions(); }) { } void SessionsBox::prepare() { @@ -99,7 +100,7 @@ void SessionsBox::prepare() { terminateAll(); }, lifetime()); - Auth().data().newAuthorizationChecks( + _session->data().newAuthorizationChecks( ) | rpl::start_with_next([=] { shortPollSessions(); }, lifetime()); diff --git a/Telegram/SourceFiles/boxes/sessions_box.h b/Telegram/SourceFiles/boxes/sessions_box.h index ddb5cd990..4eaf6e6a6 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.h +++ b/Telegram/SourceFiles/boxes/sessions_box.h @@ -18,9 +18,13 @@ class IconButton; class LinkButton; } // namespace Ui +namespace Main { +class Session; +} // namespace Main + class SessionsBox : public BoxContent, private MTP::Sender { public: - SessionsBox(QWidget*); + SessionsBox(QWidget*, not_null session); protected: void prepare() override; @@ -55,6 +59,8 @@ private: void terminateOne(uint64 hash); void terminateAll(); + const not_null _session; + bool _loading = false; Full _data; diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index 087739235..0029310cb 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "history/history_message.h" #include "window/themes/window_theme.h" +#include "window/window_session_controller.h" #include "boxes/peer_list_box.h" #include "chat_helpers/emoji_suggestions_widget.h" #include "data/data_channel.h" @@ -43,7 +44,10 @@ class ShareBox::Inner , public RPCSender , private base::Subscriber { public: - Inner(QWidget *parent, ShareBox::FilterCallback &&filterCallback); + Inner( + QWidget *parent, + not_null navigation, + ShareBox::FilterCallback &&filterCallback); void setPeerSelectedChangedCallback( Fn callback); @@ -118,6 +122,8 @@ private: void refresh(); + const not_null _navigation; + float64 _columnSkip = 0.; float64 _rowWidthReal = 0.; int _rowsLeft = 0; @@ -150,10 +156,12 @@ private: ShareBox::ShareBox( QWidget*, + not_null navigation, CopyCallback &©Callback, SubmitCallback &&submitCallback, FilterCallback &&filterCallback) -: _copyCallback(std::move(copyCallback)) +: _navigation(navigation) +, _copyCallback(std::move(copyCallback)) , _submitCallback(std::move(submitCallback)) , _filterCallback(std::move(filterCallback)) , _select( @@ -209,6 +217,7 @@ void ShareBox::prepare() { _inner = setInnerWidget( object_ptr( this, + _navigation, std::move(_filterCallback)), getTopScrollSkip(), getBottomScrollSkip()); @@ -221,7 +230,7 @@ void ShareBox::prepare() { applyFilterUpdate(query); }); _select->setItemRemovedCallback([=](uint64 itemId) { - if (const auto peer = Auth().data().peerLoaded(itemId)) { + if (const auto peer = _navigation->session().data().peerLoaded(itemId)) { _inner->peerUnselected(peer); selectedChanged(); update(); @@ -335,8 +344,8 @@ void ShareBox::peopleReceived( switch (result.type()) { case mtpc_contacts_found: { auto &found = result.c_contacts_found(); - Auth().data().processUsers(found.vusers()); - Auth().data().processChats(found.vchats()); + _navigation->session().data().processUsers(found.vusers()); + _navigation->session().data().processChats(found.vchats()); _inner->peopleReceived( query, found.vmy_results().v, @@ -479,8 +488,10 @@ void ShareBox::scrollAnimationCallback() { ShareBox::Inner::Inner( QWidget *parent, + not_null navigation, ShareBox::FilterCallback &&filterCallback) : RpWidget(parent) +, _navigation(navigation) , _filterCallback(std::move(filterCallback)) , _chatsIndexed( std::make_unique( @@ -489,7 +500,7 @@ ShareBox::Inner::Inner( _rowHeight = st::shareRowHeight; setAttribute(Qt::WA_OpaquePaintEvent); - const auto self = Auth().user(); + const auto self = _navigation->session().user(); if (_filterCallback(self)) { _chatsIndexed->addToEnd(self->owner().history(self)); } @@ -503,12 +514,12 @@ ShareBox::Inner::Inner( } } }; - addList(Auth().data().chatsList()->indexed()); + addList(_navigation->session().data().chatsList()->indexed()); const auto id = Data::Folder::kId; - if (const auto folder = Auth().data().folderLoaded(id)) { + if (const auto folder = _navigation->session().data().folderLoaded(id)) { addList(folder->chatsList()->indexed()); } - addList(Auth().data().contactsNoChatsList()); + addList(_navigation->session().data().contactsNoChatsList()); _filter = qsl("a"); updateFilter(); @@ -518,7 +529,9 @@ ShareBox::Inner::Inner( subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); })); - subscribe(Auth().downloaderTaskFinished(), [this] { update(); }); + subscribe(_navigation->session().downloaderTaskFinished(), [=] { + update(); + }); subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) { if (update.paletteChanged()) { @@ -675,7 +688,7 @@ void ShareBox::Inner::loadProfilePhotos(int yFrom) { yFrom *= _columnCount; yTo *= _columnCount; - Auth().downloader().clearPriorities(); + _navigation->session().downloader().clearPriorities(); if (_filter.isEmpty()) { if (!_chatsIndexed->empty()) { auto i = _chatsIndexed->cfind(yFrom, _rowHeight); @@ -984,8 +997,8 @@ void ShareBox::Inner::peopleReceived( d_byUsernameFiltered.reserve(already + my.size() + people.size()); const auto feedList = [&](const QVector &list) { for (const auto &data : list) { - if (const auto peer = Auth().data().peerLoaded(peerFromMTP(data))) { - const auto history = Auth().data().historyLoaded(peer); + if (const auto peer = _navigation->session().data().peerLoaded(peerFromMTP(data))) { + const auto history = _navigation->session().data().historyLoaded(peer); if (!_filterCallback(peer)) { continue; } else if (history && _chatsIndexed->getRow(history)) { @@ -1030,15 +1043,18 @@ QVector ShareBox::Inner::selected() const { return result; } -QString AppendShareGameScoreUrl(const QString &url, const FullMsgId &fullId) { +QString AppendShareGameScoreUrl( + not_null session, + const QString &url, + const FullMsgId &fullId) { auto shareHashData = QByteArray(0x10, Qt::Uninitialized); auto shareHashDataInts = reinterpret_cast(shareHashData.data()); auto channel = fullId.channel - ? Auth().data().channelLoaded(fullId.channel) + ? session->data().channelLoaded(fullId.channel) : static_cast(nullptr); auto channelAccessHash = channel ? channel->access : 0ULL; auto channelAccessHashInts = reinterpret_cast(&channelAccessHash); - shareHashDataInts[0] = Auth().userId(); + shareHashDataInts[0] = session->userId(); shareHashDataInts[1] = fullId.channel; shareHashDataInts[2] = fullId.msg; shareHashDataInts[3] = channelAccessHashInts[0]; @@ -1075,7 +1091,9 @@ QString AppendShareGameScoreUrl(const QString &url, const FullMsgId &fullId) { return url + shareComponent; } -void ShareGameScoreByHash(const QString &hash) { +void ShareGameScoreByHash( + not_null session, + const QString &hash) { auto key128Size = 0x10; auto hashEncrypted = QByteArray::fromBase64(hash.toLatin1(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); @@ -1105,7 +1123,7 @@ void ShareGameScoreByHash(const QString &hash) { } auto hashDataInts = reinterpret_cast(hashData.data()); - if (!Main::Session::Exists() || hashDataInts[0] != Auth().userId()) { + if (hashDataInts[0] != session->userId()) { Ui::show(Box(tr::lng_share_wrong_user(tr::now))); return; } @@ -1125,14 +1143,14 @@ void ShareGameScoreByHash(const QString &hash) { return; } - if (const auto item = Auth().data().message(channelId, msgId)) { + if (const auto item = session->data().message(channelId, msgId)) { FastShareMessage(item); } else { auto resolveMessageAndShareScore = [=](ChannelData *channel) { - Auth().api().requestMessageData(channel, msgId, []( + session->api().requestMessageData(channel, msgId, [=]( ChannelData *channel, MsgId msgId) { - if (const auto item = Auth().data().message(channel, msgId)) { + if (const auto item = session->data().message(channel, msgId)) { FastShareMessage(item); } else { Ui::show(Box(tr::lng_edit_deleted(tr::now))); @@ -1141,21 +1159,25 @@ void ShareGameScoreByHash(const QString &hash) { }; const auto channel = channelId - ? Auth().data().channelLoaded(channelId) + ? session->data().channelLoaded(channelId) : nullptr; if (channel || !channelId) { resolveMessageAndShareScore(channel); } else { - auto requestChannelIds = MTP_vector(1, MTP_inputChannel(MTP_int(channelId), MTP_long(channelAccessHash))); - auto requestChannel = MTPchannels_GetChannels(requestChannelIds); - MTP::send(requestChannel, rpcDone([=](const MTPmessages_Chats &result) { - result.match([](const auto &data) { - Auth().data().processChats(data.vchats()); + session->api().request(MTPchannels_GetChannels( + MTP_vector( + 1, + MTP_inputChannel( + MTP_int(channelId), + MTP_long(channelAccessHash))) + )).done([=](const MTPmessages_Chats &result) { + result.match([&](const auto &data) { + session->data().processChats(data.vchats()); }); - if (const auto channel = Auth().data().channelLoaded(channelId)) { + if (const auto channel = session->data().channelLoaded(channelId)) { resolveMessageAndShareScore(channel); } - })); + }).send(); } } } diff --git a/Telegram/SourceFiles/boxes/share_box.h b/Telegram/SourceFiles/boxes/share_box.h index 34e512ed3..7a82a226d 100644 --- a/Telegram/SourceFiles/boxes/share_box.h +++ b/Telegram/SourceFiles/boxes/share_box.h @@ -13,6 +13,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/animations.h" #include "ui/effects/round_checkbox.h" +namespace Window { +class SessionNavigation; +} // namespace Window + +namespace Main { +class Session; +} // namespace Main + namespace Dialogs { class Row; class IndexedList; @@ -30,16 +38,23 @@ template class SlideWrap; } // namespace Ui -QString AppendShareGameScoreUrl(const QString &url, const FullMsgId &fullId); -void ShareGameScoreByHash(const QString &hash); +QString AppendShareGameScoreUrl( + not_null session, + const QString &url, + const FullMsgId &fullId); +void ShareGameScoreByHash( + not_null session, + const QString &hash); class ShareBox : public BoxContent, public RPCSender { public: using CopyCallback = Fn; using SubmitCallback = Fn&&, TextWithTags&&)>; using FilterCallback = Fn; + ShareBox( QWidget*, + not_null navigation, CopyCallback &©Callback, SubmitCallback &&submitCallback, FilterCallback &&filterCallback); @@ -77,6 +92,8 @@ private: mtpRequestId requestId); bool peopleFailed(const RPCError &error, mtpRequestId requestId); + const not_null _navigation; + CopyCallback _copyCallback; SubmitCallback _submitCallback; FilterCallback _filterCallback; diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 2a45abf02..a7e0c1292 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -150,7 +150,7 @@ void StickerSetBox::prepare() { _inner = setInnerWidget( object_ptr(this, _controller, _set), st::stickersScroll); - Auth().data().stickersUpdated( + _controller->session().data().stickersUpdated( ) | rpl::start_with_next([=] { updateButtons(); }, lifetime()); @@ -166,7 +166,7 @@ void StickerSetBox::prepare() { _inner->setInstalled( ) | rpl::start_with_next([=](uint64 setId) { - Auth().api().stickerSetInstalled(setId); + _controller->session().api().stickerSetInstalled(setId); closeBox(); }, lifetime()); } @@ -234,9 +234,9 @@ StickerSetBox::Inner::Inner( Ui::show(Box(tr::lng_stickers_not_found(tr::now))); }).send(); - Auth().api().updateStickers(); + _controller->session().api().updateStickers(); - subscribe(Auth().downloaderTaskFinished(), [this] { update(); }); + subscribe(_controller->session().downloaderTaskFinished(), [this] { update(); }); setMouseTracking(true); } @@ -252,7 +252,7 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) { _pack.reserve(v.size()); _elements.reserve(v.size()); for (const auto &item : v) { - const auto document = Auth().data().processDocument(item); + const auto document = _controller->session().data().processDocument(item); const auto sticker = document->sticker(); if (!sticker) { continue; @@ -269,7 +269,7 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) { auto p = Stickers::Pack(); p.reserve(stickers.size()); for (auto j = 0, c = stickers.size(); j != c; ++j) { - auto doc = Auth().data().document(stickers[j].v); + auto doc = _controller->session().data().document(stickers[j].v); if (!doc || !doc->sticker()) continue; p.push_back(doc); @@ -292,7 +292,7 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) { } else { _setThumbnail = ImagePtr(); } - auto &sets = Auth().data().stickerSetsRef(); + auto &sets = _controller->session().data().stickerSetsRef(); const auto it = sets.find(_setId); if (it != sets.cend()) { using ClientFlag = MTPDstickerSet_ClientFlag; @@ -334,13 +334,13 @@ rpl::producer<> StickerSetBox::Inner::updateControls() const { void StickerSetBox::Inner::installDone( const MTPmessages_StickerSetInstallResult &result) { - auto &sets = Auth().data().stickerSetsRef(); + auto &sets = _controller->session().data().stickerSetsRef(); bool wasArchived = (_setFlags & MTPDstickerSet::Flag::f_archived); if (wasArchived) { - auto index = Auth().data().archivedStickerSetsOrderRef().indexOf(_setId); + auto index = _controller->session().data().archivedStickerSetsOrderRef().indexOf(_setId); if (index >= 0) { - Auth().data().archivedStickerSetsOrderRef().removeAt(index); + _controller->session().data().archivedStickerSetsOrderRef().removeAt(index); } } _setInstallDate = base::unixtime::now(); @@ -367,7 +367,7 @@ void StickerSetBox::Inner::installDone( it->stickers = _pack; it->emoji = _emoji; - auto &order = Auth().data().stickerSetsOrderRef(); + auto &order = _controller->session().data().stickerSetsOrderRef(); int insertAtIndex = 0, currentIndex = order.indexOf(_setId); if (currentIndex != insertAtIndex) { if (currentIndex > 0) { @@ -394,7 +394,7 @@ void StickerSetBox::Inner::installDone( Local::writeArchivedStickers(); } Local::writeInstalledStickers(); - Auth().data().notifyStickersUpdated(); + _controller->session().data().notifyStickersUpdated(); } _setInstalled.fire_copy(_setId); } @@ -657,8 +657,8 @@ bool StickerSetBox::Inner::notInstalled() const { if (!_loaded) { return false; } - const auto it = Auth().data().stickerSets().constFind(_setId); - if ((it == Auth().data().stickerSets().cend()) + const auto it = _controller->session().data().stickerSets().constFind(_setId); + if ((it == _controller->session().data().stickerSets().cend()) || !(it->flags & MTPDstickerSet::Flag::f_installed_date) || (it->flags & MTPDstickerSet::Flag::f_archived)) { return !_pack.empty(); diff --git a/Telegram/SourceFiles/calls/calls_box_controller.cpp b/Telegram/SourceFiles/calls/calls_box_controller.cpp index f3ffe1470..888e10493 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.cpp +++ b/Telegram/SourceFiles/calls/calls_box_controller.cpp @@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "history/history_item.h" #include "mainwidget.h" +#include "window/window_session_controller.h" #include "main/main_session.h" #include "data/data_session.h" #include "data/data_media_types.h" @@ -211,8 +212,16 @@ void BoxController::Row::stopLastActionRipple() { } } +BoxController::BoxController(not_null window) +: _window(window) { +} + +Main::Session &BoxController::session() const { + return _window->session(); +} + void BoxController::prepare() { - Auth().data().itemRemoved( + session().data().itemRemoved( ) | rpl::start_with_next([=](not_null item) { if (const auto row = rowForItem(item)) { row->itemRemoved(item); @@ -226,7 +235,7 @@ void BoxController::prepare() { } }, lifetime()); subscribe(Current().newServiceMessage(), [=](FullMsgId msgId) { - if (const auto item = Auth().data().message(msgId)) { + if (const auto item = session().data().message(msgId)) { insertRow(item, InsertWay::Prepend); } }); @@ -261,8 +270,8 @@ void BoxController::loadMoreRows() { _loadRequestId = 0; auto handleResult = [&](auto &data) { - Auth().data().processUsers(data.vusers()); - Auth().data().processChats(data.vchats()); + session().data().processUsers(data.vusers()); + session().data().processChats(data.vchats()); receivedCalls(data.vmessages().v); }; @@ -310,8 +319,8 @@ void BoxController::receivedCalls(const QVector &result) { for (const auto &message : result) { const auto msgId = IdFromMessage(message); const auto peerId = PeerFromMessage(message); - if (const auto peer = Auth().data().peerLoaded(peerId)) { - const auto item = Auth().data().addNewMessage( + if (const auto peer = session().data().peerLoaded(peerId)) { + const auto item = session().data().addNewMessage( message, NewMessageType::Existing); insertRow(item, InsertWay::Append); diff --git a/Telegram/SourceFiles/calls/calls_box_controller.h b/Telegram/SourceFiles/calls/calls_box_controller.h index 0a8c8bcd0..9833469f1 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.h +++ b/Telegram/SourceFiles/calls/calls_box_controller.h @@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/peer_list_box.h" +namespace Window { +class SessionController; +} // namespace Window + namespace Calls { class BoxController @@ -16,6 +20,9 @@ class BoxController , private base::Subscriber , private MTP::Sender { public: + explicit BoxController(not_null window); + + Main::Session &session() const override; void prepare() override; void rowClicked(not_null row) override; void rowActionClicked(not_null row) override; @@ -36,6 +43,8 @@ private: std::unique_ptr createRow( not_null item) const; + const not_null _window; + MsgId _offsetId = 0; mtpRequestId _loadRequestId = 0; bool _allLoaded = false; diff --git a/Telegram/SourceFiles/calls/calls_call.cpp b/Telegram/SourceFiles/calls/calls_call.cpp index b2413bcaf..e7405d545 100644 --- a/Telegram/SourceFiles/calls/calls_call.cpp +++ b/Telegram/SourceFiles/calls/calls_call.cpp @@ -446,7 +446,7 @@ bool Call::handleUpdate(const MTPPhoneCall &call) { } } if (data.is_need_rating() && _id && _accessHash) { - Ui::show(Box(_id, _accessHash)); + Ui::show(Box(&Auth(), _id, _accessHash)); } const auto reason = data.vreason(); if (reason && reason->type() == mtpc_phoneCallDiscardReasonDisconnect) { diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index 7942cfd6e..a6f12668d 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -139,13 +139,15 @@ GifsListWidget::GifsListWidget( this, [=] { sendInlineRequest(); }); - Auth().data().savedGifsUpdated( + controller->session().data().savedGifsUpdated( ) | rpl::start_with_next([this] { refreshSavedGifs(); }, lifetime()); - subscribe(Auth().downloaderTaskFinished(), [this] { + + subscribe(controller->session().downloaderTaskFinished(), [this] { update(); }); + subscribe(controller->gifPauseLevelChanged(), [=] { if (!controller->isGifPausedAtLeastFor( Window::GifPauseReason::SavedGifs)) { @@ -228,7 +230,7 @@ void GifsListWidget::inlineResultsDone(const MTPmessages_BotResults &result) { auto adding = (it != _inlineCache.cend()); if (result.type() == mtpc_messages_botResults) { auto &d = result.c_messages_botResults(); - Auth().data().processUsers(d.vusers()); + controller()->session().data().processUsers(d.vusers()); auto &v = d.vresults().v; auto queryId = d.vquery_id().v; @@ -492,7 +494,7 @@ void GifsListWidget::refreshSavedGifs() { if (_section == Section::Gifs) { clearInlineRows(false); - auto &saved = Auth().data().savedGifs(); + auto &saved = controller()->session().data().savedGifs(); if (!saved.isEmpty()) { _rows.reserve(saved.size()); auto row = Row(); @@ -855,12 +857,12 @@ void GifsListWidget::searchForGifs(const QString &query) { Expects(result.type() == mtpc_contacts_resolvedPeer); auto &data = result.c_contacts_resolvedPeer(); - Auth().data().processUsers(data.vusers()); - Auth().data().processChats(data.vchats()); - if (auto peer = Auth().data().peerLoaded(peerFromMTP(data.vpeer()))) { - if (auto user = peer->asUser()) { - _searchBot = user; - } + controller()->session().data().processUsers(data.vusers()); + controller()->session().data().processChats(data.vchats()); + const auto peer = controller()->session().data().peerLoaded( + peerFromMTP(data.vpeer())); + if (const auto user = peer ? peer->asUser() : nullptr) { + _searchBot = user; } }).send(); } diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index f80888243..9d0ab06c7 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -134,7 +134,7 @@ bool ShareGameScore( const auto params = url_parse_params( match->captured(1), qthelp::UrlParamNameTransform::ToLower); - ShareGameScoreByHash(params.value(qsl("hash"))); + ShareGameScoreByHash(session, params.value(qsl("hash"))); return true; } diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 7a5abb47f..e7f3b30f5 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2974,12 +2974,14 @@ void HistoryInner::changeSelectionAsGroup( } void HistoryInner::forwardItem(FullMsgId itemId) { - Window::ShowForwardMessagesBox({ 1, itemId }); + Window::ShowForwardMessagesBox(_controller, { 1, itemId }); } void HistoryInner::forwardAsGroup(FullMsgId itemId) { if (const auto item = session().data().message(itemId)) { - Window::ShowForwardMessagesBox(session().data().itemOrItsGroup(item)); + Window::ShowForwardMessagesBox( + _controller, + session().data().itemOrItsGroup(item)); } } diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index 98c603a51..33021fa9a 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -314,6 +314,7 @@ void FastShareMessage(not_null item) { ? Fn(std::move(copyCallback)) : Fn(); Ui::show(Box( + App::wnd()->sessionController(), std::move(copyLinkCallback), std::move(submitCallback), std::move(filterCallback))); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 80b7ccd27..41134ed92 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -3345,7 +3345,7 @@ void HistoryWidget::botCallbackDone( } else if (const auto url = data.vurl()) { auto link = qs(*url); if (info.game) { - link = AppendShareGameScoreUrl(link, info.msgId); + link = AppendShareGameScoreUrl(&session(), link, info.msgId); BotGameUrlClickHandler(info.bot, link).onClick({}); if (item) { updateSendAction(item->history(), SendAction::Type::PlayGame); @@ -5200,11 +5200,12 @@ void HistoryWidget::mousePressEvent(QMouseEvent *e) { if (readyToForward()) { const auto items = std::move(_toForward); App::main()->cancelForwarding(_history); - Window::ShowForwardMessagesBox(ranges::view::all( + auto list = ranges::view::all( items - ) | ranges::view::transform([](not_null item) { - return item->fullId(); - }) | ranges::to_vector); + ) | ranges::view::transform( + &HistoryItem::fullId + ) | ranges::to_vector; + Window::ShowForwardMessagesBox(controller(), std::move(list)); } else { Ui::showPeerHistory(_peer, _editMsgId ? _editMsgId : replyToId()); } @@ -6116,7 +6117,7 @@ void HistoryWidget::forwardSelected() { return; } const auto weak = make_weak(this); - Window::ShowForwardMessagesBox(getSelectedItems(), [=] { + Window::ShowForwardMessagesBox(controller(), getSelectedItems(), [=] { if (const auto strong = weak.data()) { strong->clearSelected(); } diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index ec582e384..66a5433af 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/file_utilities.h" #include "platform/platform_info.h" #include "window/window_peer_menu.h" +#include "window/window_session_controller.h" #include "lang/lang_keys.h" #include "core/application.h" #include "mainwidget.h" @@ -235,12 +236,15 @@ bool AddForwardSelectedAction( menu->addAction(tr::lng_context_forward_selected(tr::now), [=] { const auto weak = make_weak(list); - auto items = ExtractIdsList(request.selectedItems); - Window::ShowForwardMessagesBox(std::move(items), [=] { + const auto callback = [=] { if (const auto strong = weak.data()) { strong->cancelSelection(); } - }); + }; + Window::ShowForwardMessagesBox( + request.navigation, + ExtractIdsList(request.selectedItems), + callback); }); return true; } @@ -269,9 +273,11 @@ bool AddForwardMessageAction( const auto itemId = item->fullId(); menu->addAction(tr::lng_context_forward_msg(tr::now), [=] { if (const auto item = owner->message(itemId)) { - Window::ShowForwardMessagesBox(asGroup - ? owner->itemOrItsGroup(item) - : MessageIdsList{ 1, itemId }); + Window::ShowForwardMessagesBox( + request.navigation, + (asGroup + ? owner->itemOrItsGroup(item) + : MessageIdsList{ 1, itemId })); } }); return true; @@ -298,12 +304,11 @@ bool AddDeleteSelectedAction( return false; } - const auto session = request.session; menu->addAction(tr::lng_context_delete_selected(tr::now), [=] { const auto weak = make_weak(list); auto items = ExtractIdsList(request.selectedItems); const auto box = Ui::show(Box( - session, + &request.navigation->session(), std::move(items))); box->setDeleteConfirmedCallback([=] { if (const auto strong = weak.data()) { @@ -443,8 +448,9 @@ void AddCopyLinkAction( } // namespace -ContextMenuRequest::ContextMenuRequest(not_null session) -: session(session) { +ContextMenuRequest::ContextMenuRequest( + not_null navigation) +: navigation(navigation) { } base::unique_qptr FillContextMenu( diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.h b/Telegram/SourceFiles/history/view/history_view_context_menu.h index 65d870a1b..60ff07d79 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.h +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.h @@ -13,8 +13,8 @@ namespace Ui { class PopupMenu; } // namespace Ui -namespace Main { -class Session; +namespace Window { +class SessionNavigation; } // namespace Main namespace HistoryView { @@ -26,9 +26,10 @@ struct SelectedItem; using SelectedItems = std::vector; struct ContextMenuRequest { - explicit ContextMenuRequest(not_null session); + explicit ContextMenuRequest( + not_null navigation); - const not_null session; + const not_null navigation; ClickHandlerPtr link; Element *view = nullptr; HistoryItem *item = nullptr; diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 021c649a4..94c0e2010 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -1611,7 +1611,7 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { mouseActionUpdate(e->globalPos()); } - auto request = ContextMenuRequest(&_controller->session()); + auto request = ContextMenuRequest(_controller); request.link = ClickHandler::getActive(); request.view = _overElement; diff --git a/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp b/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp index b2d4526ed..47427556a 100644 --- a/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp +++ b/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp @@ -36,6 +36,7 @@ public: not_null controller, not_null user); + Main::Session &session() const override; void prepare() override; void rowClicked(not_null row) override; void loadMoreRows() override; @@ -73,6 +74,10 @@ ListController::ListController( _controller->setSearchEnabledByContent(false); } +Main::Session &ListController::session() const { + return _user->session(); +} + std::unique_ptr ListController::createRow( not_null peer) { auto result = std::make_unique(peer); diff --git a/Telegram/SourceFiles/info/info_top_bar.cpp b/Telegram/SourceFiles/info/info_top_bar.cpp index 08add27da..c25106ed1 100644 --- a/Telegram/SourceFiles/info/info_top_bar.cpp +++ b/Telegram/SourceFiles/info/info_top_bar.cpp @@ -35,11 +35,11 @@ namespace Info { TopBar::TopBar( QWidget *parent, - not_null session, + not_null navigation, const style::InfoTopBar &st, SelectedItems &&selectedItems) : RpWidget(parent) -, _session(session) +, _navigation(navigation) , _st(st) , _selectedItems(Section::MediaType::kCount) { setAttribute(Qt::WA_OpaquePaintEvent); @@ -519,7 +519,7 @@ MessageIdsList TopBar::collectItems() const { ) | ranges::view::transform([](auto &&item) { return item.msgId; }) | ranges::view::filter([&](FullMsgId msgId) { - return _session->data().message(msgId) != nullptr; + return _navigation->session().data().message(msgId) != nullptr; }) | ranges::to_vector; } @@ -530,6 +530,7 @@ void TopBar::performForward() { return; } Window::ShowForwardMessagesBox( + _navigation, std::move(items), [weak = make_weak(this)] { if (weak) { @@ -544,7 +545,7 @@ void TopBar::performDelete() { _cancelSelectionClicks.fire({}); } else { const auto box = Ui::show(Box( - _session, + &_navigation->session(), std::move(items))); box->setDeleteConfirmedCallback([weak = make_weak(this)] { if (weak) { diff --git a/Telegram/SourceFiles/info/info_top_bar.h b/Telegram/SourceFiles/info/info_top_bar.h index 3a92216b2..d44a16f63 100644 --- a/Telegram/SourceFiles/info/info_top_bar.h +++ b/Telegram/SourceFiles/info/info_top_bar.h @@ -17,6 +17,10 @@ namespace style { struct InfoTopBar; } // namespace style +namespace Window { +class SessionNavigation; +} // namespace Window + namespace Ui { class IconButton; class FlatLabel; @@ -39,7 +43,7 @@ class TopBar : public Ui::RpWidget { public: TopBar( QWidget *parent, - not_null session, + not_null navigation, const style::InfoTopBar &st, SelectedItems &&items); @@ -131,7 +135,7 @@ private: template void registerToggleControlCallback(Widget *widget, IsVisible &&callback); - const not_null _session; + const not_null _navigation; const style::InfoTopBar &_st; Ui::Animations::Simple _a_highlight; diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index 00e5aca2e..f6f879f0d 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -355,7 +355,7 @@ void WrapWidget::createTopBar() { : SelectedItems(Section::MediaType::kCount); _topBar.create( this, - &session(), + _controller.get(), TopBarStyle(wrapValue), std::move(selectedItems)); _topBar->cancelSelectionRequests( diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp index d1ee7add9..0b4807e52 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp @@ -1398,6 +1398,7 @@ void ListWidget::forwardItems(MessageIdsList &&items) { } }; setActionBoxWeak(Window::ShowForwardMessagesBox( + _controller, std::move(items), std::move(callback))); } diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index c7f230f1e..0b654c96b 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -483,19 +483,21 @@ ActionsFiller::ActionsFiller( void ActionsFiller::addInviteToGroupAction( not_null user) { + const auto controller = _controller; AddActionButton( _wrap, tr::lng_profile_invite_to_group(), CanInviteBotToGroupValue(user), - [user] { AddBotToGroupBoxController::Start(user); }); + [=] { AddBotToGroupBoxController::Start(controller, user); }); } void ActionsFiller::addShareContactAction(not_null user) { + const auto controller = _controller; AddActionButton( _wrap, tr::lng_info_share_contact(), CanShareContactValue(user), - [user] { Window::PeerMenuShareContactBox(user); }); + [=] { Window::PeerMenuShareContactBox(controller, user); }); } void ActionsFiller::addEditContactAction(not_null user) { @@ -790,14 +792,15 @@ object_ptr SetupActions( } void SetupAddChannelMember( + not_null navigation, not_null parent, not_null channel) { auto add = Ui::CreateChild( parent.get(), st::infoMembersAddMember); add->showOn(CanAddMemberValue(channel)); - add->addClickHandler([channel] { - Window::PeerMenuAddChannelMembers(channel); + add->addClickHandler([=] { + Window::PeerMenuAddChannelMembers(navigation, channel); }); parent->widthValue( ) | rpl::start_with_next([add](int newWidth) { @@ -854,7 +857,7 @@ object_ptr SetupChannelMembers( rpl::single(true), std::move(membersCallback))->entity(); - SetupAddChannelMember(button, channel); + SetupAddChannelMember(controller, button, channel); object_ptr( members, diff --git a/Telegram/SourceFiles/info/profile/info_profile_members.cpp b/Telegram/SourceFiles/info/profile/info_profile_members.cpp index b8fbaac11..e29ec6cf0 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_members.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_members.cpp @@ -324,7 +324,7 @@ void Members::updateHeaderControlsGeometry(int newWidth) { void Members::addMember() { if (const auto chat = _peer->asChat()) { - AddParticipantsBoxController::Start(chat); + AddParticipantsBoxController::Start(_controller, chat); } else if (const auto channel = _peer->asChannel()) { const auto state = _listController->saveState(); const auto users = ranges::view::all( @@ -333,6 +333,7 @@ void Members::addMember() { return peer->asUser(); }) | ranges::to_vector; AddParticipantsBoxController::Start( + _controller, channel, { users.begin(), users.end() }); } diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index c56f80332..dad8f53f8 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -3244,7 +3244,9 @@ void MainWidget::openPeerByName( if (msgId == ShowAtGameShareMsgId) { if (peer->isUser() && peer->asUser()->isBot() && !startToken.isEmpty()) { peer->asUser()->botInfo->shareGameShortName = startToken; - AddBotToGroupBoxController::Start(peer->asUser()); + AddBotToGroupBoxController::Start( + _controller, + peer->asUser()); } else { InvokeQueued(this, [this, peer] { _controller->showPeerHistory( @@ -3255,7 +3257,9 @@ void MainWidget::openPeerByName( } else if (msgId == ShowAtProfileMsgId && !peer->isChannel()) { if (peer->isUser() && peer->asUser()->isBot() && !peer->asUser()->botInfo->cantJoinGroups && !startToken.isEmpty()) { peer->asUser()->botInfo->startGroupToken = startToken; - AddBotToGroupBoxController::Start(peer->asUser()); + AddBotToGroupBoxController::Start( + _controller, + peer->asUser()); } else if (peer->isUser() && peer->asUser()->isBot()) { // Always open bot chats, even from mention links. InvokeQueued(this, [this, peer] { @@ -3317,7 +3321,9 @@ void MainWidget::usernameResolveDone(QPair msgIdAndStartToken, c if (msgId == ShowAtProfileMsgId && !peer->isChannel()) { if (peer->isUser() && peer->asUser()->isBot() && !peer->asUser()->botInfo->cantJoinGroups && !startToken.isEmpty()) { peer->asUser()->botInfo->startGroupToken = startToken; - AddBotToGroupBoxController::Start(peer->asUser()); + AddBotToGroupBoxController::Start( + _controller, + peer->asUser()); } else if (peer->isUser() && peer->asUser()->isBot()) { // Always open bot chats, even from mention links. InvokeQueued(this, [this, peer] { diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 2d9ff8887..8ada1e70d 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -602,7 +602,7 @@ void MainWindow::onShowNewGroup() { if (account().sessionExists()) { Ui::show( Box( - &account().session(), + sessionController(), GroupInfoBox::Type::Group), LayerOption::KeepOther); } @@ -611,10 +611,10 @@ void MainWindow::onShowNewGroup() { void MainWindow::onShowNewChannel() { if (isHidden()) showFromTray(); - if (_main) { + if (account().sessionExists()) { Ui::show( Box( - &account().session(), + sessionController(), GroupInfoBox::Type::Channel), LayerOption::KeepOther); } diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index c5b6be2cf..254d70b8e 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -36,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_user.h" #include "window/themes/window_theme_preview.h" #include "window/window_peer_menu.h" +#include "window/window_session_controller.h" #include "window/window_controller.h" #include "main/main_account.h" // Account::sessionValue. #include "base/unixtime.h" @@ -1260,7 +1261,9 @@ void OverlayWidget::onForward() { } close(); - Window::ShowForwardMessagesBox({ 1, item->fullId() }); + Window::ShowForwardMessagesBox( + App::wnd()->sessionController(), + { 1, item->fullId() }); } void OverlayWidget::onDelete() { diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index 23c20b8b8..c730543ee 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -673,7 +673,7 @@ void MainWindow::createGlobalMenu() { if (!account().sessionExists()) { return; } - Ui::show(Box(std::make_unique(), [](not_null box) { + Ui::show(Box(std::make_unique(sessionController()), [](not_null box) { box->addButton(tr::lng_close(), [box] { box->closeBox(); }); box->addLeftButton(tr::lng_profile_add_contact(), [] { App::wnd()->onShowAddContact(); }); })); diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp index 5ebfd852c..cf9317eb1 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp @@ -46,6 +46,10 @@ class BlockUserBoxController : public ChatsListBoxController , private base::Subscriber { public: + explicit BlockUserBoxController( + not_null navigation); + + Main::Session &session() const override; void rowClicked(not_null row) override; void setBlockUserCallback(Fn user)> callback) { @@ -63,10 +67,21 @@ protected: private: void updateIsBlocked(not_null row, UserData *user) const; + const not_null _navigation; Fn user)> _blockUserCallback; }; +BlockUserBoxController::BlockUserBoxController( + not_null 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 user) { void BlockedBoxController::BlockNewUser( not_null window) { - auto controller = std::make_unique(); + auto controller = std::make_unique(window); auto initBox = [=, controller = controller.get()]( not_null box) { controller->setBlockUserCallback([=](not_null user) { diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.h b/Telegram/SourceFiles/settings/settings_privacy_controllers.h index 669a48577..4f82aabe3 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.h +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.h @@ -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); + Main::Session &session() const override; void prepare() override; void rowClicked(not_null row) override; void rowActionClicked(not_null row) override; diff --git a/Telegram/SourceFiles/settings/settings_privacy_security.cpp b/Telegram/SourceFiles/settings/settings_privacy_security.cpp index bd48556aa..cb2642231 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_security.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_security.cpp @@ -448,7 +448,9 @@ void SetupSelfDestruction( label(), st::settingsButton )->addClickHandler([=] { - Ui::show(Box(session->api().selfDestructValue())); + Ui::show(Box( + session, + session->api().selfDestructValue())); }); AddSkip(container); @@ -464,8 +466,8 @@ void SetupSessionsList( container, tr::lng_settings_show_sessions(), st::settingsButton - )->addClickHandler([] { - Ui::show(Box()); + )->addClickHandler([=] { + Ui::show(Box(&controller->session())); }); AddSkip(container, st::settingsPrivacySecurityPadding); AddDividerText(container, tr::lng_settings_sessions_about()); diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index b7e79d989..2cda358f7 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -235,21 +235,22 @@ MainMenu::MainMenu( void MainMenu::refreshMenu() { _menu->clearActions(); if (!_controller->session().supportMode()) { + const auto controller = _controller; _menu->addAction(tr::lng_create_group_title(tr::now), [] { App::wnd()->onShowNewGroup(); }, &st::mainMenuNewGroup, &st::mainMenuNewGroupOver); _menu->addAction(tr::lng_create_channel_title(tr::now), [] { App::wnd()->onShowNewChannel(); }, &st::mainMenuNewChannel, &st::mainMenuNewChannelOver); - _menu->addAction(tr::lng_menu_contacts(tr::now), [] { - Ui::show(Box(std::make_unique(), [](not_null box) { + _menu->addAction(tr::lng_menu_contacts(tr::now), [=] { + Ui::show(Box(std::make_unique(controller), [](not_null box) { box->addButton(tr::lng_close(), [box] { box->closeBox(); }); box->addLeftButton(tr::lng_profile_add_contact(), [] { App::wnd()->onShowAddContact(); }); })); }, &st::mainMenuContacts, &st::mainMenuContactsOver); if (Global::PhoneCallsEnabled()) { - _menu->addAction(tr::lng_menu_calls(tr::now), [] { - Ui::show(Box(std::make_unique(), [](not_null box) { + _menu->addAction(tr::lng_menu_calls(tr::now), [=] { + Ui::show(Box(std::make_unique(controller), [](not_null box) { box->addButton(tr::lng_close(), [=] { box->closeBox(); }); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index a85816080..8911569a2 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -119,8 +119,10 @@ History *FindWastedPin(not_null data, Data::Folder *folder) { return nullptr; } -void AddChatMembers(not_null chat) { - AddParticipantsBoxController::Start(chat); +void AddChatMembers( + not_null navigation, + not_null chat) { + AddParticipantsBoxController::Start(navigation, chat); } bool PinnedLimitReached(Dialogs::Key key) { @@ -371,6 +373,7 @@ void Filler::addBlockUser(not_null user) { } void Filler::addUserActions(not_null user) { + const auto controller = _controller; const auto window = &_controller->window()->controller(); if (_source != PeerMenuSource::ChatsList) { if (user->session().supportMode()) { @@ -386,7 +389,7 @@ void Filler::addUserActions(not_null user) { if (user->canShareThisContact()) { _addAction( tr::lng_info_share_contact(tr::now), - [=] { PeerMenuShareContactBox(user); }); + [=] { PeerMenuShareContactBox(controller, user); }); } if (user->isContact() && !user->isSelf()) { _addAction( @@ -397,9 +400,10 @@ void Filler::addUserActions(not_null user) { [=] { PeerMenuDeleteContact(user); }); } if (user->isBot() && !user->botInfo->cantJoinGroups) { + using AddBotToGroup = AddBotToGroupBoxController; _addAction( tr::lng_profile_invite_to_group(tr::now), - [=] { AddBotToGroupBoxController::Start(user); }); + [=] { AddBotToGroup::Start(controller, user); }); } if (user->canExportChatHistory()) { _addAction( @@ -432,7 +436,7 @@ void Filler::addChatActions(not_null chat) { if (chat->canAddMembers()) { _addAction( tr::lng_profile_add_participant(tr::now), - [chat] { AddChatMembers(chat); }); + [=] { AddChatMembers(controller, chat); }); } if (chat->canSendPolls()) { _addAction( @@ -454,7 +458,8 @@ void Filler::addChatActions(not_null chat) { } void Filler::addChannelActions(not_null channel) { - auto isGroup = channel->isMegagroup(); + const auto isGroup = channel->isMegagroup(); + const auto navigation = _controller; //if (!isGroup) { // #feed // const auto feed = channel->feed(); // const auto grouped = (feed != nullptr); @@ -477,7 +482,7 @@ void Filler::addChannelActions(not_null channel) { if (channel->canAddMembers()) { _addAction( tr::lng_channel_add_members(tr::now), - [channel] { PeerMenuAddChannelMembers(channel); }); + [=] { PeerMenuAddChannelMembers(navigation, channel); }); } if (channel->canSendPolls()) { _addAction( @@ -649,7 +654,9 @@ void PeerMenuDeleteContact(not_null user) { deleteSure)); } -void PeerMenuShareContactBox(not_null user) { +void PeerMenuShareContactBox( + not_null navigation, + not_null user) { const auto weak = std::make_shared>(); auto callback = [=](not_null peer) { if (!peer->canWrite()) { @@ -680,9 +687,11 @@ void PeerMenuShareContactBox(not_null user) { }), LayerOption::KeepOther); }; *weak = Ui::show(Box( - std::make_unique(std::move(callback)), + std::make_unique( + navigation, + std::move(callback)), [](not_null box) { - box->addButton(tr::lng_cancel(), [box] { + box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); })); @@ -798,6 +807,7 @@ void PeerMenuUnblockUserWithBotRestart(not_null user) { } QPointer ShowForwardMessagesBox( + not_null navigation, MessageIdsList &&items, FnMut &&successCallback) { const auto weak = std::make_shared>(); @@ -832,12 +842,16 @@ QPointer ShowForwardMessagesBox( }); }; *weak = Ui::show(Box( - std::make_unique(std::move(callback)), + std::make_unique( + navigation, + std::move(callback)), std::move(initBox)), LayerOption::KeepOther); return weak->data(); } -void PeerMenuAddChannelMembers(not_null channel) { +void PeerMenuAddChannelMembers( + not_null navigation, + not_null channel) { if (!channel->isMegagroup() && channel->membersCount() >= Global::ChatSizeMax()) { Ui::show( @@ -864,6 +878,7 @@ void PeerMenuAddChannelMembers(not_null channel) { }) | ranges::to_vector; AddParticipantsBoxController::Start( + navigation, channel, { already.begin(), already.end() }); }); diff --git a/Telegram/SourceFiles/window/window_peer_menu.h b/Telegram/SourceFiles/window/window_peer_menu.h index a3c1fe041..9133a340f 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.h +++ b/Telegram/SourceFiles/window/window_peer_menu.h @@ -21,6 +21,7 @@ namespace Window { class Controller; class SessionController; +class SessionNavigation; enum class PeerMenuSource { ChatsList, @@ -49,8 +50,12 @@ void PeerMenuAddMuteAction( void PeerMenuExportChat(not_null peer); void PeerMenuDeleteContact(not_null user); -void PeerMenuShareContactBox(not_null user); -void PeerMenuAddChannelMembers(not_null channel); +void PeerMenuShareContactBox( + not_null navigation, + not_null user); +void PeerMenuAddChannelMembers( + not_null navigation, + not_null channel); //void PeerMenuUngroupFeed(not_null feed); // #feed void PeerMenuCreatePoll(not_null peer); void PeerMenuBlockUserBox( @@ -65,6 +70,7 @@ Fn ClearHistoryHandler(not_null peer); Fn DeleteAndLeaveHandler(not_null peer); QPointer ShowForwardMessagesBox( + not_null navigation, MessageIdsList &&items, FnMut &&successCallback = nullptr); diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 65ab217a5..58100acdc 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -107,7 +107,7 @@ SessionController::SessionController( subscribe(session->api().fullPeerUpdated(), [=](PeerData *peer) { if (peer == _showEditPeer) { _showEditPeer = nullptr; - Ui::show(Box(peer)); + Ui::show(Box(this, peer)); } });