mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Fixed format of phone number in intro widget.
This commit is contained in:
parent
5dc6bdcc42
commit
aec4857e7b
1 changed files with 9 additions and 8 deletions
|
@ -32,13 +32,18 @@ namespace Intro {
|
|||
namespace details {
|
||||
namespace {
|
||||
|
||||
bool AllowPhoneAttempt(const QString &phone) {
|
||||
[[nodiscard]] bool AllowPhoneAttempt(const QString &phone) {
|
||||
const auto digits = ranges::count_if(
|
||||
phone,
|
||||
[](QChar ch) { return ch.isNumber(); });
|
||||
return (digits > 1);
|
||||
}
|
||||
|
||||
[[nodiscard]] QString DigitsOnly(QString value) {
|
||||
static const auto RegExp = QRegularExpression("[^0-9]");
|
||||
return value.replace(RegExp, QString());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
PhoneWidget::PhoneWidget(
|
||||
|
@ -168,16 +173,12 @@ void PhoneWidget::submit() {
|
|||
cancelNearestDcRequest();
|
||||
|
||||
// Check if such account is authorized already.
|
||||
const auto digitsOnly = [](QString value) {
|
||||
static const auto RegExp = QRegularExpression("[^0-9]");
|
||||
return value.replace(RegExp, QString());
|
||||
};
|
||||
const auto phoneDigits = digitsOnly(phone);
|
||||
const auto phoneDigits = DigitsOnly(phone);
|
||||
for (const auto &[index, existing] : Core::App().domain().accounts()) {
|
||||
const auto raw = existing.get();
|
||||
if (const auto session = raw->maybeSession()) {
|
||||
if (raw->mtp().environment() == account().mtp().environment()
|
||||
&& digitsOnly(session->user()->phone()) == phoneDigits) {
|
||||
&& DigitsOnly(session->user()->phone()) == phoneDigits) {
|
||||
crl::on_main(raw, [=] {
|
||||
Core::App().domain().activate(raw);
|
||||
});
|
||||
|
@ -231,7 +232,7 @@ void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) {
|
|||
|
||||
result.match([&](const MTPDauth_sentCode &data) {
|
||||
fillSentCodeData(data);
|
||||
getData()->phone = _sentPhone;
|
||||
getData()->phone = DigitsOnly(_sentPhone);
|
||||
getData()->phoneHash = qba(data.vphone_code_hash());
|
||||
const auto next = data.vnext_type();
|
||||
if (next && next->type() == mtpc_auth_codeTypeCall) {
|
||||
|
|
Loading…
Add table
Reference in a new issue