Return 'testmode' code when no authed accounts.

This commit is contained in:
John Preston 2020-08-26 17:50:28 +04:00
parent 58008ab7b0
commit 883a62c0a2
2 changed files with 19 additions and 1 deletions

View File

@ -115,6 +115,22 @@ auto GenerateCodes() {
}
});
});
codes.emplace(qsl("testmode"), [](SessionController *window) {
auto &domain = Core::App().domain();
if (domain.started()
&& (domain.accounts().size() == 1)
&& !domain.active().sessionExists()) {
const auto environment = domain.active().mtp().environment();
domain.addActivated([&] {
return (environment == MTP::Environment::Production)
? MTP::Environment::Test
: MTP::Environment::Production;
}());
Ui::Toast::Show((environment == MTP::Environment::Production)
? "Switched to the test environment."
: "Switched to the production environment.");
}
});
codes.emplace(qsl("folders"), [](SessionController *window) {
if (window) {
window->showSettings(Settings::Type::Folders);

View File

@ -350,7 +350,9 @@ void IntroWidget::resizeEvent(QResizeEvent *e) {
}
void IntroWidget::keyPressEvent(QKeyEvent *e) {
CodesFeedString(nullptr, e->text());
crl::on_main(this, [text = e->text()]{
CodesFeedString(nullptr, text);
});
return RpWidget::keyPressEvent(e);
}