mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-02 20:38:12 +00:00
Removed methods with MTP signature from compose controls.
This commit is contained in:
parent
326304ca48
commit
3403b3c471
@ -122,7 +122,6 @@ public:
|
||||
|
||||
private:
|
||||
void updatePreview();
|
||||
void gotPreview(const MTPmessageMedia &result, const QString &links);
|
||||
void getWebPagePreview();
|
||||
|
||||
const not_null<History*> _history;
|
||||
@ -243,37 +242,6 @@ void WebpageProcessor::updatePreview() {
|
||||
_paintRequests.fire({});
|
||||
}
|
||||
|
||||
void WebpageProcessor::gotPreview(
|
||||
const MTPmessageMedia &result,
|
||||
const QString &links) {
|
||||
if (_previewRequest) {
|
||||
_previewRequest = 0;
|
||||
}
|
||||
result.match([=](const MTPDmessageMediaWebPage &d) {
|
||||
const auto page = _history->owner().processWebpage(d.vwebpage());
|
||||
_previewCache.insert({ links, page->id });
|
||||
auto &till = page->pendingTill;
|
||||
if (till > 0 && till <= base::unixtime::now()) {
|
||||
till = -1;
|
||||
}
|
||||
if (links == _previewLinks
|
||||
&& _previewState == Data::PreviewState::Allowed) {
|
||||
_previewData = (page->id && page->pendingTill >= 0)
|
||||
? page.get()
|
||||
: nullptr;
|
||||
updatePreview();
|
||||
}
|
||||
}, [=](const MTPDmessageMediaEmpty &d) {
|
||||
_previewCache.insert({ links, 0 });
|
||||
if (links == _previewLinks
|
||||
&& _previewState == Data::PreviewState::Allowed) {
|
||||
_previewData = nullptr;
|
||||
updatePreview();
|
||||
}
|
||||
}, [](const auto &d) {
|
||||
});
|
||||
}
|
||||
|
||||
void WebpageProcessor::getWebPagePreview() {
|
||||
const auto links = _previewLinks;
|
||||
_previewRequest = _api.request(
|
||||
@ -282,7 +250,32 @@ void WebpageProcessor::getWebPagePreview() {
|
||||
MTP_string(links),
|
||||
MTPVector<MTPMessageEntity>()
|
||||
)).done([=](const MTPMessageMedia &result) {
|
||||
gotPreview(result, links);
|
||||
_previewRequest = 0;
|
||||
result.match([=](const MTPDmessageMediaWebPage &d) {
|
||||
const auto page = _history->owner().processWebpage(d.vwebpage());
|
||||
_previewCache.insert({ links, page->id });
|
||||
auto &till = page->pendingTill;
|
||||
if (till > 0 && till <= base::unixtime::now()) {
|
||||
till = -1;
|
||||
}
|
||||
if (links == _previewLinks
|
||||
&& _previewState == Data::PreviewState::Allowed) {
|
||||
_previewData = (page->id && page->pendingTill >= 0)
|
||||
? page.get()
|
||||
: nullptr;
|
||||
updatePreview();
|
||||
}
|
||||
}, [=](const MTPDmessageMediaEmpty &d) {
|
||||
_previewCache.insert({ links, 0 });
|
||||
if (links == _previewLinks
|
||||
&& _previewState == Data::PreviewState::Allowed) {
|
||||
_previewData = nullptr;
|
||||
updatePreview();
|
||||
}
|
||||
}, [](const auto &d) {
|
||||
});
|
||||
}).fail([=] {
|
||||
_previewRequest = 0;
|
||||
}).send();
|
||||
}
|
||||
|
||||
@ -1899,42 +1892,6 @@ void ComposeControls::initSendAsButton() {
|
||||
}, _wrap->lifetime());
|
||||
}
|
||||
|
||||
void ComposeControls::inlineBotResolveDone(
|
||||
const MTPcontacts_ResolvedPeer &result) {
|
||||
Expects(result.type() == mtpc_contacts_resolvedPeer);
|
||||
|
||||
_inlineBotResolveRequestId = 0;
|
||||
const auto &data = result.c_contacts_resolvedPeer();
|
||||
const auto resolvedBot = [&]() -> UserData* {
|
||||
if (const auto result = session().data().processUsers(data.vusers())) {
|
||||
if (result->isBot()
|
||||
&& !result->botInfo->inlinePlaceholder.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}();
|
||||
session().data().processChats(data.vchats());
|
||||
|
||||
const auto query = ParseInlineBotQuery(&session(), _field);
|
||||
if (_inlineBotUsername == query.username) {
|
||||
applyInlineBotQuery(
|
||||
query.lookingUpBot ? resolvedBot : query.bot,
|
||||
query.query);
|
||||
} else {
|
||||
clearInlineBot();
|
||||
}
|
||||
}
|
||||
|
||||
void ComposeControls::inlineBotResolveFail(
|
||||
const MTP::Error &error,
|
||||
const QString &username) {
|
||||
_inlineBotResolveRequestId = 0;
|
||||
if (username == _inlineBotUsername) {
|
||||
clearInlineBot();
|
||||
}
|
||||
}
|
||||
|
||||
void ComposeControls::cancelInlineBot() {
|
||||
const auto &textWithTags = _field->getTextWithTags();
|
||||
if (textWithTags.text.size() > _inlineBotUsername.size() + 2) {
|
||||
@ -2580,9 +2537,36 @@ void ComposeControls::updateInlineBotQuery() {
|
||||
_inlineBotResolveRequestId = api.request(
|
||||
MTPcontacts_ResolveUsername(MTP_string(username))
|
||||
).done([=](const MTPcontacts_ResolvedPeer &result) {
|
||||
inlineBotResolveDone(result);
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
inlineBotResolveFail(error, username);
|
||||
Expects(result.type() == mtpc_contacts_resolvedPeer);
|
||||
|
||||
const auto &data = result.c_contacts_resolvedPeer();
|
||||
const auto resolvedBot = [&]() -> UserData* {
|
||||
if (const auto user = session().data().processUsers(
|
||||
data.vusers())) {
|
||||
if (user->isBot()
|
||||
&& !user->botInfo->inlinePlaceholder.isEmpty()) {
|
||||
return user;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}();
|
||||
session().data().processChats(data.vchats());
|
||||
|
||||
_inlineBotResolveRequestId = 0;
|
||||
const auto query = ParseInlineBotQuery(&session(), _field);
|
||||
if (_inlineBotUsername == query.username) {
|
||||
applyInlineBotQuery(
|
||||
query.lookingUpBot ? resolvedBot : query.bot,
|
||||
query.query);
|
||||
} else {
|
||||
clearInlineBot();
|
||||
}
|
||||
|
||||
}).fail([=] {
|
||||
_inlineBotResolveRequestId = 0;
|
||||
if (username == _inlineBotUsername) {
|
||||
clearInlineBot();
|
||||
}
|
||||
}).send();
|
||||
} else {
|
||||
applyInlineBotQuery(query.bot, query.query);
|
||||
|
@ -257,9 +257,6 @@ private:
|
||||
// Request to show results in the emoji panel.
|
||||
void applyInlineBotQuery(UserData *bot, const QString &query);
|
||||
|
||||
void inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result);
|
||||
void inlineBotResolveFail(const MTP::Error &error, const QString &username);
|
||||
|
||||
[[nodiscard]] Data::DraftKey draftKey(
|
||||
DraftType type = DraftType::Normal) const;
|
||||
[[nodiscard]] Data::DraftKey draftKeyCurrent() const;
|
||||
|
Loading…
Reference in New Issue
Block a user