2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-01 15:05:56 +00:00

Take main DC and phone prefix from active account.

This commit is contained in:
John Preston
2020-06-29 22:14:16 +04:00
parent eff340deaf
commit 90f7f482ee
5 changed files with 27 additions and 7 deletions

View File

@@ -18,7 +18,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h"
#include "main/main_account.h"
#include "main/main_domain.h"
#include "main/main_session.h"
#include "mainwindow.h"
#include "data/data_user.h"
#include "data/data_countries.h"
#include "boxes/confirm_box.h"
#include "ui/text/text_utilities.h"
#include "ui/widgets/buttons.h"
@@ -41,6 +44,20 @@ namespace {
using namespace ::Intro::details;
[[nodiscard]] QString ComputeNewAccountCountry() {
if (const auto parent
= Core::App().domain().maybeLastOrSomeAuthedAccount()) {
if (const auto session = parent->maybeSession()) {
const auto iso = ::Data::CountryISO2ByPhone(
session->user()->phone());
if (!iso.isEmpty()) {
return iso;
}
}
}
return Platform::SystemCountry();
}
} // namespace
Widget::Widget(
@@ -65,10 +82,11 @@ Widget::Widget(
rpl::single(true))) {
Core::App().setDefaultFloatPlayerDelegate(floatPlayerDelegate());
getNearestDC();
getData()->country = ComputeNewAccountCountry();
switch (point) {
case EnterPoint::Start:
getNearestDC();
appendStep(new StartWidget(this, _account, getData()));
break;
case EnterPoint::Phone:
@@ -82,8 +100,6 @@ Widget::Widget(
fixOrder();
getData()->country = Platform::SystemCountry();
_account->mtpValue(
) | rpl::start_with_next([=](not_null<MTP::Instance*> instance) {
_api.emplace(instance);