mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
[Improvement] Query parameter for tg://resolve links
This commit is contained in:
committed by
Eric Kotato
parent
8f2e15dbd2
commit
caa2d501f8
@@ -513,6 +513,12 @@ bool ResolveUsernameOrPhone(
|
|||||||
if (domain == u"telegrampassport"_q) {
|
if (domain == u"telegrampassport"_q) {
|
||||||
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;
|
||||||
@@ -598,6 +604,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")),
|
||||||
.clickFromAttachBotWebviewUrl = myContext.attachBotWebviewUrl,
|
.clickFromAttachBotWebviewUrl = myContext.attachBotWebviewUrl,
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
@@ -614,6 +614,16 @@ void SessionNavigation::showPeerByLinkResolved(
|
|||||||
: info.resolveType;
|
: info.resolveType;
|
||||||
|
|
||||||
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),
|
||||||
@@ -697,6 +707,14 @@ void SessionNavigation::showPeerByLinkResolved(
|
|||||||
if (bot || peer->isChannel()) {
|
if (bot || peer->isChannel()) {
|
||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [=] {
|
||||||
showPeerHistory(peer, params);
|
showPeerHistory(peer, params);
|
||||||
|
if (!searchQuery.isEmpty()) {
|
||||||
|
applySearchQuery();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (!searchQuery.isEmpty()) {
|
||||||
|
crl::on_main(this, [=] {
|
||||||
|
showPeerHistory(peer, params);
|
||||||
|
applySearchQuery();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
showPeerInfo(peer, params);
|
showPeerInfo(peer, params);
|
||||||
@@ -721,11 +739,15 @@ void SessionNavigation::showPeerByLinkResolved(
|
|||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [=] {
|
||||||
const auto history = peer->owner().history(peer);
|
const auto history = peer->owner().history(peer);
|
||||||
showPeerHistory(history, params, msgId);
|
showPeerHistory(history, params, msgId);
|
||||||
|
if (searchQuery.isEmpty()) {
|
||||||
peer->session().attachWebView().request(
|
peer->session().attachWebView().request(
|
||||||
parentController(),
|
parentController(),
|
||||||
Api::SendAction(history),
|
Api::SendAction(history),
|
||||||
attachBotUsername,
|
attachBotUsername,
|
||||||
info.attachBotToggleCommand.value_or(QString()));
|
info.attachBotToggleCommand.value_or(QString()));
|
||||||
|
} else {
|
||||||
|
applySearchQuery();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if (bot && info.attachBotMenuOpen) {
|
} else if (bot && info.attachBotMenuOpen) {
|
||||||
const auto startCommand = info.attachBotToggleCommand.value_or(
|
const auto startCommand = info.attachBotToggleCommand.value_or(
|
||||||
@@ -762,6 +784,9 @@ void SessionNavigation::showPeerByLinkResolved(
|
|||||||
Data::SetChatLinkDraft(peer, { draft });
|
Data::SetChatLinkDraft(peer, { draft });
|
||||||
}
|
}
|
||||||
showPeerHistory(peer, params, msgId);
|
showPeerHistory(peer, params, msgId);
|
||||||
|
if (!searchQuery.isEmpty()) {
|
||||||
|
applySearchQuery();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -49,6 +49,7 @@ struct PeerByLinkInfo {
|
|||||||
InlineBots::PeerTypes attachBotChooseTypes;
|
InlineBots::PeerTypes attachBotChooseTypes;
|
||||||
std::optional<QString> voicechatHash;
|
std::optional<QString> voicechatHash;
|
||||||
FullMsgId clickFromMessageId;
|
FullMsgId clickFromMessageId;
|
||||||
|
QString searchQuery;
|
||||||
QString clickFromAttachBotWebviewUrl;
|
QString clickFromAttachBotWebviewUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user