2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 00:55:12 +00:00

Implement switch_webview and "web_app_switch_inline_query".

This commit is contained in:
John Preston
2023-03-01 17:27:13 +04:00
committed by 23rd
parent 34c1bd950e
commit 4fe568cb82
17 changed files with 415 additions and 152 deletions

View File

@@ -434,6 +434,7 @@ void SessionNavigation::showPeerByLinkResolved(
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()));
@@ -448,13 +449,13 @@ void SessionNavigation::showPeerByLinkResolved(
? contextPeer->asUser()
: nullptr;
bot->session().attachWebView().requestAddToMenu(
bot,
*info.attachBotToggleCommand,
parentController(),
(contextUser
? Api::SendAction(
contextUser->owner().history(contextUser))
: std::optional<Api::SendAction>()),
bot,
*info.attachBotToggleCommand,
parentController(),
info.attachBotChooseTypes);
} else {
crl::on_main(this, [=] {
@@ -1150,6 +1151,54 @@ bool SessionController::jumpToChatListEntry(Dialogs::RowDescriptor row) {
return false;
}
void SessionController::setCurrentDialogsEntryState(
Dialogs::EntryState state) {
_currentDialogsEntryState = state;
}
Dialogs::EntryState SessionController::currentDialogsEntryState() const {
return _currentDialogsEntryState;
}
void SessionController::switchInlineQuery(
Dialogs::EntryState to,
not_null<UserData*> bot,
const QString &query) {
Expects(to.key.owningHistory() != nullptr);
using Section = Dialogs::EntryState::Section;
const auto history = to.key.owningHistory();
const auto textWithTags = TextWithTags{
'@' + bot->username() + ' ' + query,
TextWithTags::Tags(),
};
MessageCursor cursor = { int(textWithTags.text.size()), int(textWithTags.text.size()), QFIXED_MAX };
auto draft = std::make_unique<Data::Draft>(
textWithTags,
to.currentReplyToId,
to.rootId,
cursor,
Data::PreviewState::Allowed);
auto params = Window::SectionShow();
params.reapplyLocalDraft = true;
if (to.section == Section::Scheduled) {
history->setDraft(Data::DraftKey::Scheduled(), std::move(draft));
showSection(
std::make_shared<HistoryView::ScheduledMemento>(history),
params);
} else {
history->setLocalDraft(std::move(draft));
if (to.section == Section::Replies) {
const auto commentId = MsgId();
showRepliesForMessage(history, to.rootId, commentId, params);
} else {
showPeerHistory(history->peer, params);
}
}
}
Dialogs::RowDescriptor SessionController::resolveChatNext(
Dialogs::RowDescriptor from) const {
return content()->resolveChatNext(from);