mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Removed methods with MTP signature from compose controls.
This commit is contained in:
parent
326304ca48
commit
3403b3c471
2 changed files with 56 additions and 75 deletions
|
@ -122,7 +122,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updatePreview();
|
void updatePreview();
|
||||||
void gotPreview(const MTPmessageMedia &result, const QString &links);
|
|
||||||
void getWebPagePreview();
|
void getWebPagePreview();
|
||||||
|
|
||||||
const not_null<History*> _history;
|
const not_null<History*> _history;
|
||||||
|
@ -243,37 +242,6 @@ void WebpageProcessor::updatePreview() {
|
||||||
_paintRequests.fire({});
|
_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() {
|
void WebpageProcessor::getWebPagePreview() {
|
||||||
const auto links = _previewLinks;
|
const auto links = _previewLinks;
|
||||||
_previewRequest = _api.request(
|
_previewRequest = _api.request(
|
||||||
|
@ -282,7 +250,32 @@ void WebpageProcessor::getWebPagePreview() {
|
||||||
MTP_string(links),
|
MTP_string(links),
|
||||||
MTPVector<MTPMessageEntity>()
|
MTPVector<MTPMessageEntity>()
|
||||||
)).done([=](const MTPMessageMedia &result) {
|
)).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();
|
}).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1899,42 +1892,6 @@ void ComposeControls::initSendAsButton() {
|
||||||
}, _wrap->lifetime());
|
}, _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() {
|
void ComposeControls::cancelInlineBot() {
|
||||||
const auto &textWithTags = _field->getTextWithTags();
|
const auto &textWithTags = _field->getTextWithTags();
|
||||||
if (textWithTags.text.size() > _inlineBotUsername.size() + 2) {
|
if (textWithTags.text.size() > _inlineBotUsername.size() + 2) {
|
||||||
|
@ -2580,9 +2537,36 @@ void ComposeControls::updateInlineBotQuery() {
|
||||||
_inlineBotResolveRequestId = api.request(
|
_inlineBotResolveRequestId = api.request(
|
||||||
MTPcontacts_ResolveUsername(MTP_string(username))
|
MTPcontacts_ResolveUsername(MTP_string(username))
|
||||||
).done([=](const MTPcontacts_ResolvedPeer &result) {
|
).done([=](const MTPcontacts_ResolvedPeer &result) {
|
||||||
inlineBotResolveDone(result);
|
Expects(result.type() == mtpc_contacts_resolvedPeer);
|
||||||
}).fail([=](const MTP::Error &error) {
|
|
||||||
inlineBotResolveFail(error, username);
|
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();
|
}).send();
|
||||||
} else {
|
} else {
|
||||||
applyInlineBotQuery(query.bot, query.query);
|
applyInlineBotQuery(query.bot, query.query);
|
||||||
|
|
|
@ -257,9 +257,6 @@ private:
|
||||||
// Request to show results in the emoji panel.
|
// Request to show results in the emoji panel.
|
||||||
void applyInlineBotQuery(UserData *bot, const QString &query);
|
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(
|
[[nodiscard]] Data::DraftKey draftKey(
|
||||||
DraftType type = DraftType::Normal) const;
|
DraftType type = DraftType::Normal) const;
|
||||||
[[nodiscard]] Data::DraftKey draftKeyCurrent() const;
|
[[nodiscard]] Data::DraftKey draftKeyCurrent() const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue