mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Always start with QR-code login.
This commit is contained in:
parent
52a6282eb9
commit
ae40ea9336
3 changed files with 20 additions and 50 deletions
|
@ -83,39 +83,25 @@ PhoneWidget::PhoneWidget(
|
|||
}
|
||||
|
||||
void PhoneWidget::setupQrLogin() {
|
||||
rpl::single(
|
||||
rpl::empty_value()
|
||||
) | rpl::then(
|
||||
account().appConfig().refreshed()
|
||||
) | rpl::map([=] {
|
||||
const auto result = account().appConfig().get<QString>(
|
||||
"qr_login_code",
|
||||
"[not-set]");
|
||||
DEBUG_LOG(("PhoneWidget.qr_login_code: %1").arg(result));
|
||||
return result;
|
||||
}) | rpl::filter([](const QString &value) {
|
||||
return (value != "disabled");
|
||||
}) | rpl::take(1) | rpl::start_with_next([=] {
|
||||
const auto qrLogin = Ui::CreateChild<Ui::LinkButton>(
|
||||
this,
|
||||
tr::lng_phone_to_qr(tr::now));
|
||||
qrLogin->show();
|
||||
const auto qrLogin = Ui::CreateChild<Ui::LinkButton>(
|
||||
this,
|
||||
tr::lng_phone_to_qr(tr::now));
|
||||
qrLogin->show();
|
||||
|
||||
DEBUG_LOG(("PhoneWidget.qrLogin link created and shown."));
|
||||
DEBUG_LOG(("PhoneWidget.qrLogin link created and shown."));
|
||||
|
||||
rpl::combine(
|
||||
sizeValue(),
|
||||
qrLogin->widthValue()
|
||||
) | rpl::start_with_next([=](QSize size, int qrLoginWidth) {
|
||||
qrLogin->moveToLeft(
|
||||
(size.width() - qrLoginWidth) / 2,
|
||||
contentTop() + st::introQrLoginLinkTop);
|
||||
}, qrLogin->lifetime());
|
||||
rpl::combine(
|
||||
sizeValue(),
|
||||
qrLogin->widthValue()
|
||||
) | rpl::start_with_next([=](QSize size, int qrLoginWidth) {
|
||||
qrLogin->moveToLeft(
|
||||
(size.width() - qrLoginWidth) / 2,
|
||||
contentTop() + st::introQrLoginLinkTop);
|
||||
}, qrLogin->lifetime());
|
||||
|
||||
qrLogin->setClickedCallback([=] {
|
||||
goReplace<QrWidget>(Animate::Forward);
|
||||
});
|
||||
}, lifetime());
|
||||
qrLogin->setClickedCallback([=] {
|
||||
goReplace<QrWidget>(Animate::Forward);
|
||||
});
|
||||
}
|
||||
|
||||
void PhoneWidget::resizeEvent(QResizeEvent *e) {
|
||||
|
|
|
@ -31,15 +31,7 @@ StartWidget::StartWidget(
|
|||
|
||||
void StartWidget::submit() {
|
||||
account().destroyStaleAuthorizationKeys();
|
||||
const auto qrLogin = account().appConfig().get<QString>(
|
||||
"qr_login_code",
|
||||
"[not-set]");
|
||||
DEBUG_LOG(("qr_login_code: %1").arg(qrLogin));
|
||||
if (qrLogin == "primary") {
|
||||
goNext<QrWidget>();
|
||||
} else {
|
||||
goNext<PhoneWidget>();
|
||||
}
|
||||
goNext<QrWidget>();
|
||||
}
|
||||
|
||||
rpl::producer<QString> StartWidget::nextButtonText() const {
|
||||
|
|
|
@ -238,17 +238,9 @@ void Controller::clearPasscodeLock() {
|
|||
}
|
||||
|
||||
void Controller::setupIntro() {
|
||||
const auto parent = Core::App().domain().maybeLastOrSomeAuthedAccount();
|
||||
if (!parent) {
|
||||
_widget.setupIntro(Intro::EnterPoint::Start);
|
||||
return;
|
||||
}
|
||||
const auto qrLogin = parent->appConfig().get<QString>(
|
||||
"qr_login_code",
|
||||
"[not-set]");
|
||||
DEBUG_LOG(("qr_login_code in setup: %1").arg(qrLogin));
|
||||
const auto qr = (qrLogin == "primary");
|
||||
_widget.setupIntro(qr ? Intro::EnterPoint::Qr : Intro::EnterPoint::Phone);
|
||||
_widget.setupIntro(Core::App().domain().maybeLastOrSomeAuthedAccount()
|
||||
? Intro::EnterPoint::Qr
|
||||
: Intro::EnterPoint::Start);
|
||||
}
|
||||
|
||||
void Controller::setupMain() {
|
||||
|
|
Loading…
Add table
Reference in a new issue