| 28 | namespace details { |
| 29 | |
| 30 | CodeWidget::CodeWidget( |
| 31 | QWidget *parent, |
| 32 | not_null<Main::Account*> account, |
| 33 | not_null<Data*> data) |
| 34 | : Step(parent, account, data) |
| 35 | , _noTelegramCode(this, tr::lng_code_no_telegram(tr::now), st::introLink) |
| 36 | , _code(this) |
| 37 | , _callTimer([=] { sendCall(); }) |
| 38 | , _callStatus(getData()->callStatus) |
| 39 | , _callTimeout(getData()->callTimeout) |
| 40 | , _callLabel(this, st::introDescription) |
| 41 | , _checkRequestTimer([=] { checkRequest(); }) { |
| 42 | Lang::Updated( |
| 43 | ) | rpl::on_next([=] { |
| 44 | refreshLang(); |
| 45 | }, lifetime()); |
| 46 | |
| 47 | _noTelegramCode->addClickHandler([=] { noTelegramCode(); }); |
| 48 | |
| 49 | _code->setDigitsCountMax(getData()->codeLength); |
| 50 | |
| 51 | updateDescText(); |
| 52 | setTitleText(_isFragment.value( |
| 53 | ) | rpl::map([=](bool isFragment) { |
| 54 | return !isFragment |
| 55 | ? rpl::single(Ui::FormatPhone(getData()->phone)) |
| 56 | : tr::lng_intro_fragment_title(); |
| 57 | }) | rpl::flatten_latest()); |
| 58 | |
| 59 | account->setHandleLoginCode([=](const QString &code) { |
| 60 | _code->setCode(code); |
| 61 | _code->requestCode(); |
| 62 | }); |
| 63 | |
| 64 | _code->codeCollected( |
| 65 | ) | rpl::on_next([=](const QString &code) { |
| 66 | hideError(); |
| 67 | submitCode(code); |
| 68 | }, lifetime()); |
| 69 | } |
| 70 | |
| 71 | void CodeWidget::refreshLang() { |
| 72 | if (_noTelegramCode) { |
nothing calls this directly
no test coverage detected