mirror of https://github.com/procxx/kepka.git
Pass SessionNavigation to some boxes.
This commit is contained in:
parent
137fa0378c
commit
bacaf805b5
|
@ -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<Main::Session*> session,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
Type type,
|
||||
const QString &title,
|
||||
Fn<void(not_null<ChannelData*>)> 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<const QVector<MTPChat>*> {
|
||||
|
@ -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<ChatData*> chat) {
|
||||
if (!image.isNull()) {
|
||||
|
@ -609,7 +611,7 @@ void GroupInfoBox::submit() {
|
|||
};
|
||||
Ui::show(
|
||||
Box<PeerListBox>(
|
||||
std::make_unique<AddParticipantsBoxController>(),
|
||||
std::make_unique<AddParticipantsBoxController>(_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<const QVector<MTPChat>*> {
|
||||
|
@ -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<ChannelData*> 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<SetupChannelBox>(_createdChannel));
|
||||
Ui::show(Box<SetupChannelBox>(
|
||||
_navigation,
|
||||
_createdChannel));
|
||||
}
|
||||
}).send();
|
||||
};
|
||||
|
@ -711,9 +716,11 @@ void GroupInfoBox::updateMaxHeight() {
|
|||
|
||||
SetupChannelBox::SetupChannelBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
bool existing)
|
||||
: _channel(channel)
|
||||
: _navigation(navigation)
|
||||
, _channel(channel)
|
||||
, _existing(existing)
|
||||
, _privacyGroup(
|
||||
std::make_shared<Ui::RadioenumGroup<Privacy>>(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<SetupChannelBox>(channel, existing),
|
||||
Box<SetupChannelBox>(navigation, channel, existing),
|
||||
LayerOption::KeepOther);
|
||||
};
|
||||
closeBox();
|
||||
|
|
|
@ -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<Main::Session*> session,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
Type type,
|
||||
const QString &title = QString(),
|
||||
Fn<void(not_null<ChannelData*>)> channelDone = nullptr);
|
||||
|
@ -118,7 +122,7 @@ private:
|
|||
void descriptionResized();
|
||||
void updateMaxHeight();
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
const not_null<Window::SessionNavigation*> _navigation;
|
||||
|
||||
Type _type = Type::Group;
|
||||
QString _initialTitle;
|
||||
|
@ -138,6 +142,7 @@ class SetupChannelBox : public BoxContent, public RPCSender {
|
|||
public:
|
||||
SetupChannelBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
bool existing = false);
|
||||
|
||||
|
@ -175,6 +180,7 @@ private:
|
|||
|
||||
void showRevokePublicLinkBoxForEdit();
|
||||
|
||||
const not_null<Window::SessionNavigation*> _navigation;
|
||||
const not_null<ChannelData*> _channel;
|
||||
|
||||
bool _existing = false;
|
||||
|
|
|
@ -34,8 +34,11 @@ namespace {
|
|||
class PrivacyExceptionsBoxController : public ChatsListBoxController {
|
||||
public:
|
||||
PrivacyExceptionsBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
rpl::producer<QString> title,
|
||||
const std::vector<not_null<PeerData*>> &selected);
|
||||
|
||||
Main::Session &session() const override;
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
|
||||
std::vector<not_null<PeerData*>> getResult() const;
|
||||
|
@ -45,18 +48,26 @@ protected:
|
|||
std::unique_ptr<Row> createRow(not_null<History*> history) override;
|
||||
|
||||
private:
|
||||
not_null<Window::SessionNavigation*> _navigation;
|
||||
rpl::producer<QString> _title;
|
||||
std::vector<not_null<PeerData*>> _selected;
|
||||
|
||||
};
|
||||
|
||||
PrivacyExceptionsBoxController::PrivacyExceptionsBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
rpl::producer<QString> title,
|
||||
const std::vector<not_null<PeerData*>> &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<void()> done) {
|
||||
auto controller = std::make_unique<PrivacyExceptionsBoxController>(
|
||||
_window,
|
||||
_controller->exceptionBoxTitle(exception),
|
||||
exceptions(exception));
|
||||
auto initBox = [=, controller = controller.get()](
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<PeerListRow*> row) = 0;
|
||||
virtual Main::Session &session() const = 0;
|
||||
virtual void rowActionClicked(not_null<PeerListRow*> row) {
|
||||
}
|
||||
virtual void loadMoreRows() {
|
||||
|
|
|
@ -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<Window::SessionNavigation*> 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<MTPPeer> &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(history) {
|
||||
}
|
||||
|
||||
ChatsListBoxController::ChatsListBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation)
|
||||
: ChatsListBoxController(
|
||||
std::make_unique<PeerListGlobalSearchController>(navigation)) {
|
||||
}
|
||||
|
||||
ChatsListBoxController::ChatsListBoxController(
|
||||
std::unique_ptr<PeerListSearchController> 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*> history) {
|
|||
}
|
||||
|
||||
ContactsBoxController::ContactsBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation)
|
||||
: PeerListController(
|
||||
std::make_unique<PeerListGlobalSearchController>(navigation))
|
||||
, _navigation(navigation) {
|
||||
}
|
||||
|
||||
ContactsBoxController::ContactsBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
std::unique_ptr<PeerListSearchController> 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<PeerListRow> ContactsBoxController::createRow(not_null<UserData*
|
|||
return std::make_unique<PeerListRow>(user);
|
||||
}
|
||||
|
||||
void AddBotToGroupBoxController::Start(not_null<UserData*> bot) {
|
||||
void AddBotToGroupBoxController::Start(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<UserData*> bot) {
|
||||
auto initBox = [=](not_null<PeerListBox*> box) {
|
||||
box->addButton(tr::lng_cancel(), [box] { box->closeBox(); });
|
||||
};
|
||||
Ui::show(Box<PeerListBox>(std::make_unique<AddBotToGroupBoxController>(bot), std::move(initBox)));
|
||||
Ui::show(Box<PeerListBox>(
|
||||
std::make_unique<AddBotToGroupBoxController>(navigation, bot),
|
||||
std::move(initBox)));
|
||||
}
|
||||
|
||||
AddBotToGroupBoxController::AddBotToGroupBoxController(not_null<UserData*> bot)
|
||||
AddBotToGroupBoxController::AddBotToGroupBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<UserData*> bot)
|
||||
: ChatsListBoxController(SharingBotGame(bot)
|
||||
? std::make_unique<PeerListGlobalSearchController>()
|
||||
? std::make_unique<PeerListGlobalSearchController>(navigation)
|
||||
: nullptr)
|
||||
, _bot(bot) {
|
||||
}
|
||||
|
||||
Main::Session &AddBotToGroupBoxController::session() const {
|
||||
return _bot->session();
|
||||
}
|
||||
|
||||
void AddBotToGroupBoxController::rowClicked(not_null<PeerListRow*> 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<Window::SessionNavigation*> navigation,
|
||||
FnMut<void(not_null<PeerData*>)> callback)
|
||||
: _callback(std::move(callback)) {
|
||||
: ChatsListBoxController(navigation)
|
||||
, _navigation(navigation)
|
||||
, _callback(std::move(callback)) {
|
||||
}
|
||||
|
||||
Main::Session &ChooseRecipientBoxController::session() const {
|
||||
return _navigation->session();
|
||||
}
|
||||
|
||||
void ChooseRecipientBoxController::prepareViewHook() {
|
||||
|
|
|
@ -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<Window::SessionNavigation*> 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<Window::SessionNavigation*> _navigation;
|
||||
base::Timer _timer;
|
||||
QString _query;
|
||||
mtpRequestId _requestId = 0;
|
||||
|
@ -78,9 +86,9 @@ private:
|
|||
|
||||
class ChatsListBoxController : public PeerListController {
|
||||
public:
|
||||
ChatsListBoxController(not_null<Window::SessionNavigation*> navigation);
|
||||
ChatsListBoxController(
|
||||
std::unique_ptr<PeerListSearchController> searchController
|
||||
= std::make_unique<PeerListGlobalSearchController>());
|
||||
std::unique_ptr<PeerListSearchController> searchController);
|
||||
|
||||
void prepare() override final;
|
||||
std::unique_ptr<PeerListRow> createSearchRow(not_null<PeerData*> peer) override final;
|
||||
|
@ -114,9 +122,12 @@ private:
|
|||
class ContactsBoxController : public PeerListController {
|
||||
public:
|
||||
ContactsBoxController(
|
||||
std::unique_ptr<PeerListSearchController> searchController
|
||||
= std::make_unique<PeerListGlobalSearchController>());
|
||||
not_null<Window::SessionNavigation*> navigation);
|
||||
ContactsBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
std::unique_ptr<PeerListSearchController> searchController);
|
||||
|
||||
Main::Session &session() const override;
|
||||
void prepare() override final;
|
||||
std::unique_ptr<PeerListRow> createSearchRow(not_null<PeerData*> peer) override final;
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
|
@ -133,16 +144,23 @@ private:
|
|||
void checkForEmptyRows();
|
||||
bool appendRow(not_null<UserData*> user);
|
||||
|
||||
const not_null<Window::SessionNavigation*> _navigation;
|
||||
|
||||
};
|
||||
|
||||
class AddBotToGroupBoxController
|
||||
: public ChatsListBoxController
|
||||
, public base::has_weak_ptr {
|
||||
public:
|
||||
static void Start(not_null<UserData*> bot);
|
||||
static void Start(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<UserData*> bot);
|
||||
|
||||
AddBotToGroupBoxController(not_null<UserData*> bot);
|
||||
AddBotToGroupBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<UserData*> bot);
|
||||
|
||||
Main::Session &session() const override;
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
|
||||
protected:
|
||||
|
@ -171,8 +189,10 @@ class ChooseRecipientBoxController
|
|||
, public base::has_weak_ptr {
|
||||
public:
|
||||
ChooseRecipientBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
FnMut<void(not_null<PeerData*>)> callback);
|
||||
|
||||
Main::Session &session() const override;
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
|
||||
bool respectSavedMessagesChat() const override {
|
||||
|
@ -185,6 +205,7 @@ protected:
|
|||
not_null<History*> history) override;
|
||||
|
||||
private:
|
||||
const not_null<Window::SessionNavigation*> _navigation;
|
||||
FnMut<void(not_null<PeerData*>)> _callback;
|
||||
|
||||
};
|
||||
|
|
|
@ -47,20 +47,29 @@ base::flat_set<not_null<UserData*>> GetAlreadyInFromPeer(PeerData *peer) {
|
|||
|
||||
} // namespace
|
||||
|
||||
AddParticipantsBoxController::AddParticipantsBoxController()
|
||||
AddParticipantsBoxController::AddParticipantsBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation)
|
||||
: ContactsBoxController(
|
||||
std::make_unique<PeerListGlobalSearchController>()) {
|
||||
navigation,
|
||||
std::make_unique<PeerListGlobalSearchController>(navigation)) {
|
||||
}
|
||||
|
||||
AddParticipantsBoxController::AddParticipantsBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer)
|
||||
: AddParticipantsBoxController(peer, GetAlreadyInFromPeer(peer)) {
|
||||
: AddParticipantsBoxController(
|
||||
navigation,
|
||||
peer,
|
||||
GetAlreadyInFromPeer(peer)) {
|
||||
}
|
||||
|
||||
AddParticipantsBoxController::AddParticipantsBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer,
|
||||
base::flat_set<not_null<UserData*>> &&alreadyIn)
|
||||
: ContactsBoxController(std::make_unique<PeerListGlobalSearchController>())
|
||||
: ContactsBoxController(
|
||||
navigation,
|
||||
std::make_unique<PeerListGlobalSearchController>(navigation))
|
||||
, _peer(peer)
|
||||
, _alreadyIn(std::move(alreadyIn)) {
|
||||
subscribeToMigration();
|
||||
|
@ -180,8 +189,12 @@ bool AddParticipantsBoxController::inviteSelectedUsers(
|
|||
return true;
|
||||
}
|
||||
|
||||
void AddParticipantsBoxController::Start(not_null<ChatData*> chat) {
|
||||
auto controller = std::make_unique<AddParticipantsBoxController>(chat);
|
||||
void AddParticipantsBoxController::Start(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChatData*> chat) {
|
||||
auto controller = std::make_unique<AddParticipantsBoxController>(
|
||||
navigation,
|
||||
chat);
|
||||
const auto weak = controller.get();
|
||||
auto initBox = [=](not_null<PeerListBox*> box) {
|
||||
box->addButton(tr::lng_participant_invite(), [=] {
|
||||
|
@ -199,10 +212,12 @@ void AddParticipantsBoxController::Start(not_null<ChatData*> chat) {
|
|||
}
|
||||
|
||||
void AddParticipantsBoxController::Start(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
base::flat_set<not_null<UserData*>> &&alreadyIn,
|
||||
bool justCreated) {
|
||||
auto controller = std::make_unique<AddParticipantsBoxController>(
|
||||
navigation,
|
||||
channel,
|
||||
std::move(alreadyIn));
|
||||
const auto weak = controller.get();
|
||||
|
@ -238,13 +253,16 @@ void AddParticipantsBoxController::Start(
|
|||
}
|
||||
|
||||
void AddParticipantsBoxController::Start(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
base::flat_set<not_null<UserData*>> &&alreadyIn) {
|
||||
Start(channel, std::move(alreadyIn), false);
|
||||
Start(navigation, channel, std::move(alreadyIn), false);
|
||||
}
|
||||
|
||||
void AddParticipantsBoxController::Start(not_null<ChannelData*> channel) {
|
||||
Start(channel, {}, true);
|
||||
void AddParticipantsBoxController::Start(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> 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,
|
||||
|
|
|
@ -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<ChatData*> chat);
|
||||
static void Start(not_null<ChannelData*> channel);
|
||||
static void Start(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChatData*> chat);
|
||||
static void Start(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel);
|
||||
static void Start(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
base::flat_set<not_null<UserData*>> &&alreadyIn);
|
||||
|
||||
AddParticipantsBoxController();
|
||||
AddParticipantsBoxController(not_null<PeerData*> peer);
|
||||
explicit AddParticipantsBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation);
|
||||
AddParticipantsBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer);
|
||||
AddParticipantsBoxController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer,
|
||||
base::flat_set<not_null<UserData*>> &&alreadyIn);
|
||||
|
||||
|
@ -34,6 +47,7 @@ protected:
|
|||
|
||||
private:
|
||||
static void Start(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
base::flat_set<not_null<UserData*>> &&alreadyIn,
|
||||
bool justCreated);
|
||||
|
@ -73,6 +87,7 @@ public:
|
|||
AdminDoneCallback adminDoneCallback,
|
||||
BannedDoneCallback bannedDoneCallback);
|
||||
|
||||
Main::Session &session() const override;
|
||||
void prepare() override;
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
void loadMoreRows() override;
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
const std::vector<not_null<PeerData*>> &chats,
|
||||
Fn<void(ChannelData*)> callback);
|
||||
|
||||
Main::Session &session() const override;
|
||||
void prepare() override;
|
||||
void rowClicked(not_null<PeerListRow*> 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<Ui::RpWidget> SetupFooter(
|
|||
|
||||
object_ptr<Ui::RpWidget> SetupCreateGroup(
|
||||
not_null<QWidget*> parent,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
Fn<void(ChannelData*)> callback) {
|
||||
Expects(channel->isBroadcast());
|
||||
|
@ -245,7 +251,7 @@ object_ptr<Ui::RpWidget> SetupCreateGroup(
|
|||
const auto guarded = crl::guard(parent, callback);
|
||||
Ui::show(
|
||||
Box<GroupInfoBox>(
|
||||
&channel->session(),
|
||||
navigation,
|
||||
GroupInfoBox::Type::Megagroup,
|
||||
channel->name + " Chat",
|
||||
guarded),
|
||||
|
@ -271,6 +277,7 @@ object_ptr<Ui::RpWidget> SetupUnlink(
|
|||
}
|
||||
|
||||
object_ptr<BoxContent> EditLinkedChatBox(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
ChannelData *chat,
|
||||
std::vector<not_null<PeerData*>> &&chats,
|
||||
|
@ -284,7 +291,11 @@ object_ptr<BoxContent> 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<BoxContent> EditLinkedChatBox(
|
|||
} // namespace
|
||||
|
||||
object_ptr<BoxContent> EditLinkedChatBox(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
std::vector<not_null<PeerData*>> &&chats,
|
||||
Fn<void(ChannelData*)> callback) {
|
||||
return EditLinkedChatBox(
|
||||
navigation,
|
||||
channel,
|
||||
nullptr,
|
||||
std::move(chats),
|
||||
|
@ -325,9 +338,16 @@ object_ptr<BoxContent> EditLinkedChatBox(
|
|||
}
|
||||
|
||||
object_ptr<BoxContent> EditLinkedChatBox(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
not_null<ChannelData*> chat,
|
||||
bool canEdit,
|
||||
Fn<void(ChannelData*)> callback) {
|
||||
return EditLinkedChatBox(channel, chat, {}, canEdit, callback);
|
||||
return EditLinkedChatBox(
|
||||
navigation,
|
||||
channel,
|
||||
chat,
|
||||
{},
|
||||
canEdit,
|
||||
callback);
|
||||
}
|
||||
|
|
|
@ -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<BoxContent> EditLinkedChatBox(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
not_null<ChannelData*> chat,
|
||||
bool canEdit,
|
||||
Fn<void(ChannelData*)> callback);
|
||||
|
||||
object_ptr<BoxContent> EditLinkedChatBox(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
std::vector<not_null<PeerData*>> &&chats,
|
||||
Fn<void(ChannelData*)> callback);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -149,6 +149,7 @@ public:
|
|||
not_null<PeerData*> peer,
|
||||
Role role);
|
||||
|
||||
Main::Session &session() const override;
|
||||
void prepare() override;
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
void rowActionClicked(not_null<PeerListRow*> row) override;
|
||||
|
|
|
@ -243,6 +243,7 @@ class Controller
|
|||
, private MTP::Sender {
|
||||
public:
|
||||
Controller(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<BoxContent*> box,
|
||||
not_null<PeerData*> peer);
|
||||
|
||||
|
@ -328,9 +329,10 @@ private:
|
|||
std::optional<QString> _usernameSavedValue;
|
||||
std::optional<bool> _signaturesSavedValue;
|
||||
|
||||
not_null<BoxContent*> _box;
|
||||
const not_null<Window::SessionNavigation*> _navigation;
|
||||
const not_null<BoxContent*> _box;
|
||||
not_null<PeerData*> _peer;
|
||||
bool _isGroup = false;
|
||||
const bool _isGroup = false;
|
||||
|
||||
base::unique_qptr<Ui::VerticalLayout> _wrap;
|
||||
Controls _controls;
|
||||
|
@ -348,18 +350,20 @@ private:
|
|||
};
|
||||
|
||||
Controller::Controller(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<BoxContent*> box,
|
||||
not_null<PeerData*> 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<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer)
|
||||
: _peer(peer->migrateToOrMe()) {
|
||||
: _navigation(navigation)
|
||||
, _peer(peer->migrateToOrMe()) {
|
||||
}
|
||||
|
||||
void EditPeerInfoBox::prepare() {
|
||||
const auto controller = Ui::CreateChild<Controller>(this, this, _peer);
|
||||
const auto controller = Ui::CreateChild<Controller>(
|
||||
this,
|
||||
_navigation,
|
||||
this,
|
||||
_peer);
|
||||
_focusRequests.events(
|
||||
) | rpl::start_with_next(
|
||||
[=] { controller->setFocus(); },
|
||||
|
|
|
@ -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<PeerData*> peer);
|
||||
EditPeerInfoBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer);
|
||||
|
||||
void setInnerFocus() override {
|
||||
_focusRequests.fire({});
|
||||
|
@ -47,6 +54,7 @@ protected:
|
|||
|
||||
private:
|
||||
rpl::event_stream<> _focusRequests;
|
||||
not_null<Window::SessionNavigation*> _navigation;
|
||||
not_null<PeerData*> _peer;
|
||||
|
||||
};
|
||||
|
|
|
@ -25,8 +25,13 @@ constexpr auto kRateCallCommentLengthMax = 200;
|
|||
|
||||
} // namespace
|
||||
|
||||
RateCallBox::RateCallBox(QWidget*, uint64 callId, uint64 callAccessHash)
|
||||
: _callId(callId)
|
||||
RateCallBox::RateCallBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> 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<Ui::IconButton>(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();
|
||||
}
|
||||
|
|
|
@ -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<Main::Session*> session,
|
||||
uint64 callId,
|
||||
uint64 callAccessHash);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
@ -32,6 +40,8 @@ private:
|
|||
void send();
|
||||
void commentResized();
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
|
||||
uint64 _callId = 0;
|
||||
uint64 _callAccessHash = 0;
|
||||
int _rating = 0;
|
||||
|
|
|
@ -16,8 +16,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
SelfDestructionBox::SelfDestructionBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
rpl::producer<int> 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(); });
|
||||
|
|
|
@ -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<int> preloaded);
|
||||
SelfDestructionBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
rpl::producer<int> preloaded);
|
||||
|
||||
static QString DaysLabel(int days);
|
||||
|
||||
|
@ -29,6 +36,7 @@ private:
|
|||
void gotCurrent(int days);
|
||||
void showContent();
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
bool _prepared = false;
|
||||
std::vector<int> _ttlValues;
|
||||
object_ptr<Ui::FlatLabel> _description = { nullptr };
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,8 +75,9 @@ private:
|
|||
|
||||
};
|
||||
|
||||
SessionsBox::SessionsBox(QWidget*)
|
||||
: _shortPollTimer([=] { shortPollSessions(); }) {
|
||||
SessionsBox::SessionsBox(QWidget*, not_null<Main::Session*> 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());
|
||||
|
|
|
@ -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<Main::Session*> session);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
@ -55,6 +59,8 @@ private:
|
|||
void terminateOne(uint64 hash);
|
||||
void terminateAll();
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
|
||||
bool _loading = false;
|
||||
Full _data;
|
||||
|
||||
|
|
|
@ -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<Window::SessionNavigation*> navigation,
|
||||
ShareBox::FilterCallback &&filterCallback);
|
||||
|
||||
void setPeerSelectedChangedCallback(
|
||||
Fn<void(PeerData *peer, bool selected)> callback);
|
||||
|
@ -118,6 +122,8 @@ private:
|
|||
|
||||
void refresh();
|
||||
|
||||
const not_null<Window::SessionNavigation*> _navigation;
|
||||
|
||||
float64 _columnSkip = 0.;
|
||||
float64 _rowWidthReal = 0.;
|
||||
int _rowsLeft = 0;
|
||||
|
@ -150,10 +156,12 @@ private:
|
|||
|
||||
ShareBox::ShareBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionNavigation*> 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<Inner>(
|
||||
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<Window::SessionNavigation*> navigation,
|
||||
ShareBox::FilterCallback &&filterCallback)
|
||||
: RpWidget(parent)
|
||||
, _navigation(navigation)
|
||||
, _filterCallback(std::move(filterCallback))
|
||||
, _chatsIndexed(
|
||||
std::make_unique<Dialogs::IndexedList>(
|
||||
|
@ -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<MTPPeer> &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<PeerData*> ShareBox::Inner::selected() const {
|
|||
return result;
|
||||
}
|
||||
|
||||
QString AppendShareGameScoreUrl(const QString &url, const FullMsgId &fullId) {
|
||||
QString AppendShareGameScoreUrl(
|
||||
not_null<Main::Session*> session,
|
||||
const QString &url,
|
||||
const FullMsgId &fullId) {
|
||||
auto shareHashData = QByteArray(0x10, Qt::Uninitialized);
|
||||
auto shareHashDataInts = reinterpret_cast<int32*>(shareHashData.data());
|
||||
auto channel = fullId.channel
|
||||
? Auth().data().channelLoaded(fullId.channel)
|
||||
? session->data().channelLoaded(fullId.channel)
|
||||
: static_cast<ChannelData*>(nullptr);
|
||||
auto channelAccessHash = channel ? channel->access : 0ULL;
|
||||
auto channelAccessHashInts = reinterpret_cast<int32*>(&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<Main::Session*> 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<int32*>(hashData.data());
|
||||
if (!Main::Session::Exists() || hashDataInts[0] != Auth().userId()) {
|
||||
if (hashDataInts[0] != session->userId()) {
|
||||
Ui::show(Box<InformBox>(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<InformBox>(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<MTPInputChannel>(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<MTPInputChannel>(
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 <typename Widget>
|
|||
class SlideWrap;
|
||||
} // namespace Ui
|
||||
|
||||
QString AppendShareGameScoreUrl(const QString &url, const FullMsgId &fullId);
|
||||
void ShareGameScoreByHash(const QString &hash);
|
||||
QString AppendShareGameScoreUrl(
|
||||
not_null<Main::Session*> session,
|
||||
const QString &url,
|
||||
const FullMsgId &fullId);
|
||||
void ShareGameScoreByHash(
|
||||
not_null<Main::Session*> session,
|
||||
const QString &hash);
|
||||
|
||||
class ShareBox : public BoxContent, public RPCSender {
|
||||
public:
|
||||
using CopyCallback = Fn<void()>;
|
||||
using SubmitCallback = Fn<void(QVector<PeerData*>&&, TextWithTags&&)>;
|
||||
using FilterCallback = Fn<bool(PeerData*)>;
|
||||
|
||||
ShareBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
CopyCallback &©Callback,
|
||||
SubmitCallback &&submitCallback,
|
||||
FilterCallback &&filterCallback);
|
||||
|
@ -77,6 +92,8 @@ private:
|
|||
mtpRequestId requestId);
|
||||
bool peopleFailed(const RPCError &error, mtpRequestId requestId);
|
||||
|
||||
const not_null<Window::SessionNavigation*> _navigation;
|
||||
|
||||
CopyCallback _copyCallback;
|
||||
SubmitCallback _submitCallback;
|
||||
FilterCallback _filterCallback;
|
||||
|
|
|
@ -150,7 +150,7 @@ void StickerSetBox::prepare() {
|
|||
_inner = setInnerWidget(
|
||||
object_ptr<Inner>(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<InformBox>(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();
|
||||
|
|
|
@ -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::SessionController*> 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<const HistoryItem*> 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<MTPMessage> &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);
|
||||
|
|
|
@ -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::SessionController*> window);
|
||||
|
||||
Main::Session &session() const override;
|
||||
void prepare() override;
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
void rowActionClicked(not_null<PeerListRow*> row) override;
|
||||
|
@ -36,6 +43,8 @@ private:
|
|||
std::unique_ptr<PeerListRow> createRow(
|
||||
not_null<HistoryItem*> item) const;
|
||||
|
||||
const not_null<Window::SessionController*> _window;
|
||||
|
||||
MsgId _offsetId = 0;
|
||||
mtpRequestId _loadRequestId = 0;
|
||||
bool _allLoaded = false;
|
||||
|
|
|
@ -446,7 +446,7 @@ bool Call::handleUpdate(const MTPPhoneCall &call) {
|
|||
}
|
||||
}
|
||||
if (data.is_need_rating() && _id && _accessHash) {
|
||||
Ui::show(Box<RateCallBox>(_id, _accessHash));
|
||||
Ui::show(Box<RateCallBox>(&Auth(), _id, _accessHash));
|
||||
}
|
||||
const auto reason = data.vreason();
|
||||
if (reason && reason->type() == mtpc_phoneCallDiscardReasonDisconnect) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -314,6 +314,7 @@ void FastShareMessage(not_null<HistoryItem*> item) {
|
|||
? Fn<void()>(std::move(copyCallback))
|
||||
: Fn<void()>();
|
||||
Ui::show(Box<ShareBox>(
|
||||
App::wnd()->sessionController(),
|
||||
std::move(copyLinkCallback),
|
||||
std::move(submitCallback),
|
||||
std::move(filterCallback)));
|
||||
|
|
|
@ -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<HistoryItem*> 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();
|
||||
}
|
||||
|
|
|
@ -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<DeleteMessagesBox>(
|
||||
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<Main::Session*> session)
|
||||
: session(session) {
|
||||
ContextMenuRequest::ContextMenuRequest(
|
||||
not_null<Window::SessionNavigation*> navigation)
|
||||
: navigation(navigation) {
|
||||
}
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
||||
|
|
|
@ -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<SelectedItem>;
|
||||
|
||||
struct ContextMenuRequest {
|
||||
explicit ContextMenuRequest(not_null<Main::Session*> session);
|
||||
explicit ContextMenuRequest(
|
||||
not_null<Window::SessionNavigation*> navigation);
|
||||
|
||||
const not_null<Main::Session*> session;
|
||||
const not_null<Window::SessionNavigation*> navigation;
|
||||
ClickHandlerPtr link;
|
||||
Element *view = nullptr;
|
||||
HistoryItem *item = nullptr;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
not_null<Controller*> controller,
|
||||
not_null<UserData*> user);
|
||||
|
||||
Main::Session &session() const override;
|
||||
void prepare() override;
|
||||
void rowClicked(not_null<PeerListRow*> 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<PeerListRow> ListController::createRow(
|
||||
not_null<PeerData*> peer) {
|
||||
auto result = std::make_unique<PeerListRow>(peer);
|
||||
|
|
|
@ -35,11 +35,11 @@ namespace Info {
|
|||
|
||||
TopBar::TopBar(
|
||||
QWidget *parent,
|
||||
not_null<Main::Session*> session,
|
||||
not_null<Window::SessionNavigation*> 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<DeleteMessagesBox>(
|
||||
_session,
|
||||
&_navigation->session(),
|
||||
std::move(items)));
|
||||
box->setDeleteConfirmedCallback([weak = make_weak(this)] {
|
||||
if (weak) {
|
||||
|
|
|
@ -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<Main::Session*> session,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
const style::InfoTopBar &st,
|
||||
SelectedItems &&items);
|
||||
|
||||
|
@ -131,7 +135,7 @@ private:
|
|||
template <typename Widget, typename IsVisible>
|
||||
void registerToggleControlCallback(Widget *widget, IsVisible &&callback);
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
const not_null<Window::SessionNavigation*> _navigation;
|
||||
|
||||
const style::InfoTopBar &_st;
|
||||
Ui::Animations::Simple _a_highlight;
|
||||
|
|
|
@ -355,7 +355,7 @@ void WrapWidget::createTopBar() {
|
|||
: SelectedItems(Section::MediaType::kCount);
|
||||
_topBar.create(
|
||||
this,
|
||||
&session(),
|
||||
_controller.get(),
|
||||
TopBarStyle(wrapValue),
|
||||
std::move(selectedItems));
|
||||
_topBar->cancelSelectionRequests(
|
||||
|
|
|
@ -1398,6 +1398,7 @@ void ListWidget::forwardItems(MessageIdsList &&items) {
|
|||
}
|
||||
};
|
||||
setActionBoxWeak(Window::ShowForwardMessagesBox(
|
||||
_controller,
|
||||
std::move(items),
|
||||
std::move(callback)));
|
||||
}
|
||||
|
|
|
@ -483,19 +483,21 @@ ActionsFiller::ActionsFiller(
|
|||
|
||||
void ActionsFiller::addInviteToGroupAction(
|
||||
not_null<UserData*> 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<UserData*> 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<UserData*> user) {
|
||||
|
@ -790,14 +792,15 @@ object_ptr<Ui::RpWidget> SetupActions(
|
|||
}
|
||||
|
||||
void SetupAddChannelMember(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<ChannelData*> channel) {
|
||||
auto add = Ui::CreateChild<Ui::IconButton>(
|
||||
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<Ui::RpWidget> SetupChannelMembers(
|
|||
rpl::single(true),
|
||||
std::move(membersCallback))->entity();
|
||||
|
||||
SetupAddChannelMember(button, channel);
|
||||
SetupAddChannelMember(controller, button, channel);
|
||||
|
||||
object_ptr<FloatingIcon>(
|
||||
members,
|
||||
|
|
|
@ -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() });
|
||||
}
|
||||
|
|
|
@ -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<MsgId, QString> 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] {
|
||||
|
|
|
@ -602,7 +602,7 @@ void MainWindow::onShowNewGroup() {
|
|||
if (account().sessionExists()) {
|
||||
Ui::show(
|
||||
Box<GroupInfoBox>(
|
||||
&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<GroupInfoBox>(
|
||||
&account().session(),
|
||||
sessionController(),
|
||||
GroupInfoBox::Type::Channel),
|
||||
LayerOption::KeepOther);
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -673,7 +673,7 @@ void MainWindow::createGlobalMenu() {
|
|||
if (!account().sessionExists()) {
|
||||
return;
|
||||
}
|
||||
Ui::show(Box<PeerListBox>(std::make_unique<ContactsBoxController>(), [](not_null<PeerListBox*> box) {
|
||||
Ui::show(Box<PeerListBox>(std::make_unique<ContactsBoxController>(sessionController()), [](not_null<PeerListBox*> box) {
|
||||
box->addButton(tr::lng_close(), [box] { box->closeBox(); });
|
||||
box->addLeftButton(tr::lng_profile_add_contact(), [] { App::wnd()->onShowAddContact(); });
|
||||
}));
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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<PeerListBox>(std::make_unique<ContactsBoxController>(), [](not_null<PeerListBox*> box) {
|
||||
_menu->addAction(tr::lng_menu_contacts(tr::now), [=] {
|
||||
Ui::show(Box<PeerListBox>(std::make_unique<ContactsBoxController>(controller), [](not_null<PeerListBox*> 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<PeerListBox>(std::make_unique<Calls::BoxController>(), [](not_null<PeerListBox*> box) {
|
||||
_menu->addAction(tr::lng_menu_calls(tr::now), [=] {
|
||||
Ui::show(Box<PeerListBox>(std::make_unique<Calls::BoxController>(controller), [](not_null<PeerListBox*> box) {
|
||||
box->addButton(tr::lng_close(), [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
|
|
|
@ -119,8 +119,10 @@ History *FindWastedPin(not_null<Data::Session*> data, Data::Folder *folder) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void AddChatMembers(not_null<ChatData*> chat) {
|
||||
AddParticipantsBoxController::Start(chat);
|
||||
void AddChatMembers(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChatData*> chat) {
|
||||
AddParticipantsBoxController::Start(navigation, chat);
|
||||
}
|
||||
|
||||
bool PinnedLimitReached(Dialogs::Key key) {
|
||||
|
@ -371,6 +373,7 @@ void Filler::addBlockUser(not_null<UserData*> user) {
|
|||
}
|
||||
|
||||
void Filler::addUserActions(not_null<UserData*> 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<UserData*> 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<UserData*> 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<ChatData*> 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<ChatData*> chat) {
|
|||
}
|
||||
|
||||
void Filler::addChannelActions(not_null<ChannelData*> 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<ChannelData*> 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<UserData*> user) {
|
|||
deleteSure));
|
||||
}
|
||||
|
||||
void PeerMenuShareContactBox(not_null<UserData*> user) {
|
||||
void PeerMenuShareContactBox(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<UserData*> user) {
|
||||
const auto weak = std::make_shared<QPointer<PeerListBox>>();
|
||||
auto callback = [=](not_null<PeerData*> peer) {
|
||||
if (!peer->canWrite()) {
|
||||
|
@ -680,9 +687,11 @@ void PeerMenuShareContactBox(not_null<UserData*> user) {
|
|||
}), LayerOption::KeepOther);
|
||||
};
|
||||
*weak = Ui::show(Box<PeerListBox>(
|
||||
std::make_unique<ChooseRecipientBoxController>(std::move(callback)),
|
||||
std::make_unique<ChooseRecipientBoxController>(
|
||||
navigation,
|
||||
std::move(callback)),
|
||||
[](not_null<PeerListBox*> box) {
|
||||
box->addButton(tr::lng_cancel(), [box] {
|
||||
box->addButton(tr::lng_cancel(), [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
}));
|
||||
|
@ -798,6 +807,7 @@ void PeerMenuUnblockUserWithBotRestart(not_null<UserData*> user) {
|
|||
}
|
||||
|
||||
QPointer<Ui::RpWidget> ShowForwardMessagesBox(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
MessageIdsList &&items,
|
||||
FnMut<void()> &&successCallback) {
|
||||
const auto weak = std::make_shared<QPointer<PeerListBox>>();
|
||||
|
@ -832,12 +842,16 @@ QPointer<Ui::RpWidget> ShowForwardMessagesBox(
|
|||
});
|
||||
};
|
||||
*weak = Ui::show(Box<PeerListBox>(
|
||||
std::make_unique<ChooseRecipientBoxController>(std::move(callback)),
|
||||
std::make_unique<ChooseRecipientBoxController>(
|
||||
navigation,
|
||||
std::move(callback)),
|
||||
std::move(initBox)), LayerOption::KeepOther);
|
||||
return weak->data();
|
||||
}
|
||||
|
||||
void PeerMenuAddChannelMembers(not_null<ChannelData*> channel) {
|
||||
void PeerMenuAddChannelMembers(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel) {
|
||||
if (!channel->isMegagroup()
|
||||
&& channel->membersCount() >= Global::ChatSizeMax()) {
|
||||
Ui::show(
|
||||
|
@ -864,6 +878,7 @@ void PeerMenuAddChannelMembers(not_null<ChannelData*> channel) {
|
|||
}) | ranges::to_vector;
|
||||
|
||||
AddParticipantsBoxController::Start(
|
||||
navigation,
|
||||
channel,
|
||||
{ already.begin(), already.end() });
|
||||
});
|
||||
|
|
|
@ -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<PeerData*> peer);
|
||||
void PeerMenuDeleteContact(not_null<UserData*> user);
|
||||
void PeerMenuShareContactBox(not_null<UserData*> user);
|
||||
void PeerMenuAddChannelMembers(not_null<ChannelData*> channel);
|
||||
void PeerMenuShareContactBox(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<UserData*> user);
|
||||
void PeerMenuAddChannelMembers(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel);
|
||||
//void PeerMenuUngroupFeed(not_null<Data::Feed*> feed); // #feed
|
||||
void PeerMenuCreatePoll(not_null<PeerData*> peer);
|
||||
void PeerMenuBlockUserBox(
|
||||
|
@ -65,6 +70,7 @@ Fn<void()> ClearHistoryHandler(not_null<PeerData*> peer);
|
|||
Fn<void()> DeleteAndLeaveHandler(not_null<PeerData*> peer);
|
||||
|
||||
QPointer<Ui::RpWidget> ShowForwardMessagesBox(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
MessageIdsList &&items,
|
||||
FnMut<void()> &&successCallback = nullptr);
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ SessionController::SessionController(
|
|||
subscribe(session->api().fullPeerUpdated(), [=](PeerData *peer) {
|
||||
if (peer == _showEditPeer) {
|
||||
_showEditPeer = nullptr;
|
||||
Ui::show(Box<EditPeerInfoBox>(peer));
|
||||
Ui::show(Box<EditPeerInfoBox>(this, peer));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue