2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 06:07:45 +00:00

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

This commit is contained in:
RadRussianRus 2022-09-11 06:19:58 +03:00 committed by Eric Kotato
parent 8f2e15dbd2
commit caa2d501f8
3 changed files with 38 additions and 5 deletions

View File

@ -513,6 +513,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;
@ -598,6 +604,7 @@ bool ResolveUsernameOrPhone(
? std::make_optional(params.value(u"voicechat"_q))
: std::nullopt),
.clickFromMessageId = myContext.itemId,
.searchQuery = params.value(qsl("query")),
.clickFromAttachBotWebviewUrl = myContext.attachBotWebviewUrl,
});
return true;

View File

@ -614,6 +614,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),
@ -697,6 +707,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);
@ -721,11 +739,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.attachBotMenuOpen) {
const auto startCommand = info.attachBotToggleCommand.value_or(
@ -762,6 +784,9 @@ void SessionNavigation::showPeerByLinkResolved(
Data::SetChatLinkDraft(peer, { draft });
}
showPeerHistory(peer, params, msgId);
if (!searchQuery.isEmpty()) {
applySearchQuery();
}
});
}
}

View File

@ -49,6 +49,7 @@ struct PeerByLinkInfo {
InlineBots::PeerTypes attachBotChooseTypes;
std::optional<QString> voicechatHash;
FullMsgId clickFromMessageId;
QString searchQuery;
QString clickFromAttachBotWebviewUrl;
};