mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Fix webview switch_inline to the same chat.
This commit is contained in:
@@ -1184,7 +1184,7 @@ Dialogs::EntryState SessionController::currentDialogsEntryState() const {
|
||||
return _currentDialogsEntryState;
|
||||
}
|
||||
|
||||
void SessionController::switchInlineQuery(
|
||||
bool SessionController::switchInlineQuery(
|
||||
Dialogs::EntryState to,
|
||||
not_null<UserData*> bot,
|
||||
const QString &query) {
|
||||
@@ -1192,6 +1192,12 @@ void SessionController::switchInlineQuery(
|
||||
|
||||
using Section = Dialogs::EntryState::Section;
|
||||
|
||||
const auto thread = to.key.thread();
|
||||
if (!thread || !Data::CanSend(thread, ChatRestriction::SendInline)) {
|
||||
show(Ui::MakeInformBox(tr::lng_inline_switch_cant()));
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto history = to.key.owningHistory();
|
||||
const auto textWithTags = TextWithTags{
|
||||
'@' + bot->username() + ' ' + query,
|
||||
@@ -1214,6 +1220,7 @@ void SessionController::switchInlineQuery(
|
||||
params);
|
||||
} else {
|
||||
history->setLocalDraft(std::move(draft));
|
||||
history->clearLocalEditDraft(to.rootId);
|
||||
if (to.section == Section::Replies) {
|
||||
const auto commentId = MsgId();
|
||||
showRepliesForMessage(history, to.rootId, commentId, params);
|
||||
@@ -1221,6 +1228,21 @@ void SessionController::switchInlineQuery(
|
||||
showPeerHistory(history->peer, params);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SessionController::switchInlineQuery(
|
||||
not_null<Data::Thread*> thread,
|
||||
not_null<UserData*> bot,
|
||||
const QString &query) {
|
||||
const auto entryState = Dialogs::EntryState{
|
||||
.key = thread,
|
||||
.section = (thread->asTopic()
|
||||
? Dialogs::EntryState::Section::Replies
|
||||
: Dialogs::EntryState::Section::History),
|
||||
.rootId = thread->topicRootId(),
|
||||
};
|
||||
return switchInlineQuery(entryState, bot, query);
|
||||
}
|
||||
|
||||
Dialogs::RowDescriptor SessionController::resolveChatNext(
|
||||
|
@@ -379,10 +379,14 @@ public:
|
||||
|
||||
void setCurrentDialogsEntryState(Dialogs::EntryState state);
|
||||
[[nodiscard]] Dialogs::EntryState currentDialogsEntryState() const;
|
||||
void switchInlineQuery(
|
||||
bool switchInlineQuery(
|
||||
Dialogs::EntryState to,
|
||||
not_null<UserData*> bot,
|
||||
const QString &query);
|
||||
bool switchInlineQuery(
|
||||
not_null<Data::Thread*> thread,
|
||||
not_null<UserData*> bot,
|
||||
const QString &query);
|
||||
|
||||
[[nodiscard]] Dialogs::RowDescriptor resolveChatNext(
|
||||
Dialogs::RowDescriptor from = {}) const;
|
||||
|
Reference in New Issue
Block a user