[Improvement] Query parameter for tg://resolve links
This commit is contained in:
parent
a00aa9a032
commit
5862f16ce7
2 changed files with 36 additions and 4 deletions
|
|
@ -338,6 +338,12 @@ bool ResolveUsernameOrPhone(
|
||||||
if (domain == qsl("telegrampassport")) {
|
if (domain == qsl("telegrampassport")) {
|
||||||
return ShowPassportForm(controller, params);
|
return ShowPassportForm(controller, params);
|
||||||
} else if (!validDomain(domain) && !validPhone(phone)) {
|
} else if (!validDomain(domain) && !validPhone(phone)) {
|
||||||
|
const auto searchParam = params.value(qsl("query"));
|
||||||
|
if (!searchParam.isEmpty()) {
|
||||||
|
controller->content()->searchMessages(
|
||||||
|
searchParam + ' ',
|
||||||
|
Dialogs::Key());
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
using ResolveType = Window::ResolveType;
|
using ResolveType = Window::ResolveType;
|
||||||
|
|
@ -403,6 +409,7 @@ bool ResolveUsernameOrPhone(
|
||||||
? std::make_optional(params.value(u"voicechat"_q))
|
? std::make_optional(params.value(u"voicechat"_q))
|
||||||
: std::nullopt),
|
: std::nullopt),
|
||||||
.clickFromMessageId = myContext.itemId,
|
.clickFromMessageId = myContext.itemId,
|
||||||
|
.searchQuery = params.value(qsl("query")),
|
||||||
});
|
});
|
||||||
controller->window().activate();
|
controller->window().activate();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -372,6 +372,16 @@ void SessionNavigation::showPeerByLinkResolved(
|
||||||
const auto user = peer->asUser();
|
const auto user = peer->asUser();
|
||||||
const auto bot = (user && user->isBot()) ? user : nullptr;
|
const auto bot = (user && user->isBot()) ? user : nullptr;
|
||||||
const auto &replies = info.repliesInfo;
|
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)) {
|
if (const auto threadId = std::get_if<ThreadId>(&replies)) {
|
||||||
showRepliesForMessage(
|
showRepliesForMessage(
|
||||||
session().data().history(peer),
|
session().data().history(peer),
|
||||||
|
|
@ -407,6 +417,14 @@ void SessionNavigation::showPeerByLinkResolved(
|
||||||
if (bot || peer->isChannel()) {
|
if (bot || peer->isChannel()) {
|
||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [=] {
|
||||||
showPeerHistory(peer->id, params);
|
showPeerHistory(peer->id, params);
|
||||||
|
if (!searchQuery.isEmpty()) {
|
||||||
|
applySearchQuery();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (!searchQuery.isEmpty()) {
|
||||||
|
crl::on_main(this, [=] {
|
||||||
|
showPeerHistory(peer->id, params);
|
||||||
|
applySearchQuery();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
showPeerInfo(peer, params);
|
showPeerInfo(peer, params);
|
||||||
|
|
@ -428,10 +446,14 @@ void SessionNavigation::showPeerByLinkResolved(
|
||||||
if (!attachBotUsername.isEmpty()) {
|
if (!attachBotUsername.isEmpty()) {
|
||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [=] {
|
||||||
showPeerHistory(peer->id, params, msgId);
|
showPeerHistory(peer->id, params, msgId);
|
||||||
|
if (searchQuery.isEmpty()) {
|
||||||
peer->session().attachWebView().request(
|
peer->session().attachWebView().request(
|
||||||
peer,
|
peer,
|
||||||
attachBotUsername,
|
attachBotUsername,
|
||||||
info.attachBotToggleCommand.value_or(QString()));
|
info.attachBotToggleCommand.value_or(QString()));
|
||||||
|
} else {
|
||||||
|
applySearchQuery();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if (bot && info.attachBotToggleCommand) {
|
} else if (bot && info.attachBotToggleCommand) {
|
||||||
const auto itemId = info.clickFromMessageId;
|
const auto itemId = info.clickFromMessageId;
|
||||||
|
|
@ -451,6 +473,9 @@ void SessionNavigation::showPeerByLinkResolved(
|
||||||
} else {
|
} else {
|
||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [=] {
|
||||||
showPeerHistory(peer->id, params, msgId);
|
showPeerHistory(peer->id, params, msgId);
|
||||||
|
if (!searchQuery.isEmpty()) {
|
||||||
|
applySearchQuery();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue