mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Showed slash button in field only when bots have registered commands.
This commit is contained in:
@@ -5844,9 +5844,9 @@ bool HistoryWidget::updateCmdStartShown() {
|
||||
if (_history
|
||||
&& _peer
|
||||
&& (false
|
||||
|| (_peer->isChat() && _peer->asChat()->botStatus == Data::BotStatus::HasBots)
|
||||
|| (_peer->isChat() && !_peer->asChat()->botCommands().empty())
|
||||
|| (_peer->isMegagroup()
|
||||
&& _peer->asChannel()->mgInfo->botStatus == Data::BotStatus::HasBots))) {
|
||||
&& !_peer->asChannel()->mgInfo->botCommands().empty()))) {
|
||||
if (!isBotStart()
|
||||
&& !isBlocked()
|
||||
&& !_keyboard->hasMarkup()
|
||||
|
||||
@@ -3696,12 +3696,18 @@ bool ComposeControls::hasEnoughLinesForAi() const {
|
||||
bool ComposeControls::updateBotCommandShown() {
|
||||
auto shown = false;
|
||||
const auto peer = _history ? _history->peer.get() : nullptr;
|
||||
if (_botCommandStart
|
||||
&& peer
|
||||
&& ((peer->isChat() && peer->asChat()->botStatus == Data::BotStatus::HasBots)
|
||||
|| (peer->isMegagroup() && peer->asChannel()->mgInfo->botStatus == Data::BotStatus::HasBots)
|
||||
|| (peer->isUser() && peer->asUser()->isBot()))) {
|
||||
if (!HasSendText(_field)) {
|
||||
if (_botCommandStart && peer) {
|
||||
const auto hasBotCommands = [&] {
|
||||
if (peer->isChat()) {
|
||||
return !peer->asChat()->botCommands().empty();
|
||||
} else if (peer->isMegagroup()) {
|
||||
return !peer->asChannel()->mgInfo->botCommands().empty();
|
||||
} else if (peer->isUser()) {
|
||||
return peer->asUser()->isBot();
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
if (hasBotCommands && !HasSendText(_field)) {
|
||||
shown = true;
|
||||
}
|
||||
}
|
||||
@@ -4187,6 +4193,16 @@ void ComposeControls::initWebpageProcess() {
|
||||
}
|
||||
}, _historyLifetime);
|
||||
|
||||
session().data().botCommandsChanges(
|
||||
) | rpl::filter([peer = _history->peer](not_null<PeerData*> p) {
|
||||
return (p == peer);
|
||||
}) | rpl::on_next([=] {
|
||||
if (updateBotCommandShown()) {
|
||||
updateControlsVisibility();
|
||||
updateControlsGeometry(_wrap->size());
|
||||
}
|
||||
}, _historyLifetime);
|
||||
|
||||
_header->previewReady(_preview->parsedValue());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user