Fn<bool( Ui::InputField::EditLinkSelection selection, QString text, QString link, EditLinkAction action)> DefaultEditLinkCallback( not_null<Window::Controller*> controller, not_null<Ui::InputField*> field) { const auto weak = make_weak(field); return [=]( EditLinkSelection selection, QString text, QString link, EditLinkAction action) { if (action == EditLinkAction::Check) { return Ui::InputField::IsValidMarkdownLink(link) && !IsMentionLink(link); } Ui::show(Box<EditLinkBox>(text, link, [=]( const QString &text, const QString &link) { if (const auto strong = weak.data()) { strong->commitMarkdownLinkEdit(selection, text, link); } }), LayerOption::KeepOther); return true; }; }
void ChangePhoneBox::EnterCode::submit() { if (_requestId) { return; } hideError(); const auto code = _code->getDigitsOnly(); _requestId = MTP::send(MTPaccount_ChangePhone( MTP_string(_phone), MTP_string(_hash), MTP_string(code) ), rpcDone([weak = make_weak(this)](const MTPUser &result) { App::feedUser(result); if (weak) { Ui::hideLayer(); } Ui::Toast::Show(lang(lng_change_phone_success)); }), rpcFail(crl::guard(this, [this](const RPCError &error) { return sendCodeFail(error); }))); }