Remove MTP from requestDeepLinkInfo interface.

This commit is contained in:
John Preston 2022-08-10 15:27:41 +03:00
parent ab3d3a449b
commit 566128c3eb
3 changed files with 15 additions and 13 deletions

View file

@ -293,14 +293,20 @@ void ApiWrap::topPromotionDone(const MTPhelp_PromoData &proxy) {
void ApiWrap::requestDeepLinkInfo(
const QString &path,
Fn<void(const MTPDhelp_deepLinkInfo &result)> callback) {
Fn<void(TextWithEntities message, bool updateRequired)> callback) {
request(_deepLinkInfoRequestId).cancel();
_deepLinkInfoRequestId = request(MTPhelp_GetDeepLinkInfo(
MTP_string(path)
)).done([=](const MTPhelp_DeepLinkInfo &result) {
_deepLinkInfoRequestId = 0;
if (result.type() == mtpc_help_deepLinkInfo) {
callback(result.c_help_deepLinkInfo());
const auto &data = result.c_help_deepLinkInfo();
callback(TextWithEntities{
qs(data.vmessage()),
Api::EntitiesFromMTP(
_session,
data.ventities().value_or_empty())
}, data.is_update_app());
}
}).fail([=] {
_deepLinkInfoRequestId = 0;

View file

@ -192,7 +192,7 @@ public:
void refreshTopPromotion();
void requestDeepLinkInfo(
const QString &path,
Fn<void(const MTPDhelp_deepLinkInfo &result)> callback);
Fn<void(TextWithEntities message, bool updateRequired)> callback);
void requestTermsUpdate();
void acceptTerms(bytes::const_span termsId);

View file

@ -491,25 +491,21 @@ bool HandleUnknown(
return false;
}
const auto request = match->captured(1);
const auto callback = crl::guard(controller, [=](const MTPDhelp_deepLinkInfo &result) {
const auto text = TextWithEntities{
qs(result.vmessage()),
Api::EntitiesFromMTP(
&controller->session(),
result.ventities().value_or_empty())
};
if (result.is_update_app()) {
const auto callback = crl::guard(controller, [=](
TextWithEntities message,
bool updateRequired) {
if (updateRequired) {
const auto callback = [=](Fn<void()> &&close) {
Core::UpdateApplication();
close();
};
controller->show(Ui::MakeConfirmBox({
.text = text,
.text = message,
.confirmed = callback,
.confirmText = tr::lng_menu_update(),
}));
} else {
controller->show(Ui::MakeInformBox(text));
controller->show(Ui::MakeInformBox(message));
}
});
controller->session().api().requestDeepLinkInfo(request, callback);