[Improvement] Query parameter for tg://resolve links

This commit is contained in:
Eric Kotato 2022-09-11 06:19:58 +03:00 committed by Eric Kotato
parent ecc93b7a30
commit 41fa23ee54
2 changed files with 37 additions and 5 deletions

View file

@ -361,6 +361,12 @@ bool ResolveUsernameOrPhone(
if (domain == u"telegrampassport"_q) {
return ShowPassportForm(controller, params);
} else if (!validDomain(domain) && !validPhone(phone)) {
const auto searchParam = params.value(qsl("query"));
if (!searchParam.isEmpty()) {
controller->content()->searchMessages(
searchParam + ' ',
Dialogs::Key());
}
return false;
}
using ResolveType = Window::ResolveType;
@ -438,6 +444,7 @@ bool ResolveUsernameOrPhone(
? std::make_optional(params.value(u"voicechat"_q))
: std::nullopt),
.clickFromMessageId = myContext.itemId,
.searchQuery = params.value(qsl("query")),
});
controller->window().activate();
return true;

View file

@ -520,6 +520,16 @@ void SessionNavigation::showPeerByLinkResolved(
: info.resolveType;
const auto &replies = info.repliesInfo;
const auto searchQuery = info.searchQuery;
const auto applySearchQuery = [=] {
parentController()->content()->searchMessages(
searchQuery + ' ',
(peer && !peer->isUser())
? peer->owner().history(peer).get()
: Dialogs::Key());
};
if (const auto threadId = std::get_if<ThreadId>(&replies)) {
showRepliesForMessage(
session().data().history(peer),
@ -588,6 +598,14 @@ void SessionNavigation::showPeerByLinkResolved(
if (bot || peer->isChannel()) {
crl::on_main(this, [=] {
showPeerHistory(peer, params);
if (!searchQuery.isEmpty()) {
applySearchQuery();
}
});
} else if (!searchQuery.isEmpty()) {
crl::on_main(this, [=] {
showPeerHistory(peer, params);
applySearchQuery();
});
} else {
showPeerInfo(peer, params);
@ -610,11 +628,15 @@ void SessionNavigation::showPeerByLinkResolved(
crl::on_main(this, [=] {
const auto history = peer->owner().history(peer);
showPeerHistory(history, params, msgId);
peer->session().attachWebView().request(
parentController(),
Api::SendAction(history),
attachBotUsername,
info.attachBotToggleCommand.value_or(QString()));
if (searchQuery.isEmpty()) {
peer->session().attachWebView().request(
parentController(),
Api::SendAction(history),
attachBotUsername,
info.attachBotToggleCommand.value_or(QString()));
} else {
applySearchQuery();
}
});
} else if (bot && info.attachBotToggleCommand) {
const auto itemId = info.clickFromMessageId;
@ -637,6 +659,9 @@ void SessionNavigation::showPeerByLinkResolved(
} else {
crl::on_main(this, [=] {
showPeerHistory(peer, params, msgId);
if (!searchQuery.isEmpty()) {
applySearchQuery();
}
});
}
}