mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Remove some more Auth() calls.
This commit is contained in:
@@ -55,6 +55,7 @@ void SetupLanguageButton(
|
||||
}
|
||||
|
||||
void SetupSections(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
Fn<void(Type)> showOther) {
|
||||
AddDivider(container);
|
||||
@@ -71,8 +72,8 @@ void SetupSections(
|
||||
icon
|
||||
)->addClickHandler([=] { showOther(type); });
|
||||
};
|
||||
if (Auth().supportMode()) {
|
||||
SetupSupport(container);
|
||||
if (controller->session().supportMode()) {
|
||||
SetupSupport(controller, container);
|
||||
|
||||
AddDivider(container);
|
||||
AddSkip(container);
|
||||
@@ -227,51 +228,50 @@ void SetupFaq(not_null<Ui::VerticalLayout*> container, bool icon) {
|
||||
)->addClickHandler(OpenFaq);
|
||||
}
|
||||
|
||||
void SetupHelp(not_null<Ui::VerticalLayout*> container) {
|
||||
void SetupHelp(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
AddDivider(container);
|
||||
AddSkip(container);
|
||||
|
||||
SetupFaq(container);
|
||||
|
||||
if (::Main::Session::Exists()) {
|
||||
const auto button = AddButton(
|
||||
container,
|
||||
tr::lng_settings_ask_question(),
|
||||
st::settingsSectionButton);
|
||||
button->addClickHandler([=] {
|
||||
const auto ready = crl::guard(button, [](const MTPUser &data) {
|
||||
if (const auto user = Auth().data().processUser(data)) {
|
||||
Ui::showPeerHistory(user, ShowAtUnreadMsgId);
|
||||
}
|
||||
});
|
||||
const auto sure = crl::guard(button, [=] {
|
||||
Auth().api().requestSupportContact(ready);
|
||||
});
|
||||
auto box = Box<ConfirmBox>(
|
||||
tr::lng_settings_ask_sure(tr::now),
|
||||
tr::lng_settings_ask_ok(tr::now),
|
||||
tr::lng_settings_faq_button(tr::now),
|
||||
sure,
|
||||
OpenFaq);
|
||||
box->setStrictCancel(true);
|
||||
Ui::show(std::move(box));
|
||||
const auto button = AddButton(
|
||||
container,
|
||||
tr::lng_settings_ask_question(),
|
||||
st::settingsSectionButton);
|
||||
button->addClickHandler([=] {
|
||||
const auto ready = crl::guard(button, [=](const MTPUser &data) {
|
||||
if (const auto user = controller->session().data().processUser(data)) {
|
||||
Ui::showPeerHistory(user, ShowAtUnreadMsgId);
|
||||
}
|
||||
});
|
||||
}
|
||||
const auto sure = crl::guard(button, [=] {
|
||||
controller->session().api().requestSupportContact(ready);
|
||||
});
|
||||
auto box = Box<ConfirmBox>(
|
||||
tr::lng_settings_ask_sure(tr::now),
|
||||
tr::lng_settings_ask_ok(tr::now),
|
||||
tr::lng_settings_faq_button(tr::now),
|
||||
sure,
|
||||
OpenFaq);
|
||||
box->setStrictCancel(true);
|
||||
Ui::show(std::move(box));
|
||||
});
|
||||
|
||||
AddSkip(container);
|
||||
}
|
||||
|
||||
Main::Main(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<UserData*> self)
|
||||
not_null<Window::SessionController*> controller)
|
||||
: Section(parent)
|
||||
, _self(self) {
|
||||
, _controller(controller) {
|
||||
setupContent(controller);
|
||||
}
|
||||
|
||||
void Main::keyPressEvent(QKeyEvent *e) {
|
||||
CodesFeedString(e->text());
|
||||
CodesFeedString(&_controller->session(), e->text());
|
||||
return Section::keyPressEvent(e);
|
||||
}
|
||||
|
||||
@@ -280,11 +280,11 @@ void Main::setupContent(not_null<Window::SessionController*> controller) {
|
||||
|
||||
const auto cover = content->add(object_ptr<Info::Profile::Cover>(
|
||||
content,
|
||||
_self,
|
||||
controller->session().user(),
|
||||
controller));
|
||||
cover->setOnlineCount(rpl::single(0));
|
||||
|
||||
SetupSections(content, [=](Type type) {
|
||||
SetupSections(controller, content, [=](Type type) {
|
||||
_showOther.fire_copy(type);
|
||||
});
|
||||
if (HasInterfaceScale()) {
|
||||
@@ -293,7 +293,7 @@ void Main::setupContent(not_null<Window::SessionController*> controller) {
|
||||
SetupInterfaceScale(content);
|
||||
AddSkip(content);
|
||||
}
|
||||
SetupHelp(content);
|
||||
SetupHelp(controller, content);
|
||||
|
||||
Ui::ResizeFitChild(this, content);
|
||||
|
||||
|
Reference in New Issue
Block a user