2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

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