From 3fd62d51aa8d004f528af34a05db7e8d5f756a0b Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 30 Dec 2020 16:27:32 +0400 Subject: [PATCH] Hide bot command start button when editing message. Fixes #9941. --- Telegram/SourceFiles/history/history_widget.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 7208241d8..b59ec772a 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1661,6 +1661,7 @@ void HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) { _editMsgId = 0; _replyToId = readyToForward() ? 0 : _history->localDraft()->msgId; } + updateCmdStartShown(); updateControlsVisibility(); updateControlsGeometry(); refreshTopBarActiveChat(); @@ -2228,11 +2229,7 @@ void HistoryWidget::updateControlsVisibility() { _botCommandStart->hide(); } else { _botKeyboardShow->hide(); - if (_cmdStartShown) { - _botCommandStart->show(); - } else { - _botCommandStart->hide(); - } + _botCommandStart->setVisible(_cmdStartShown); } } _attachToggle->show(); @@ -3738,7 +3735,7 @@ void HistoryWidget::updateSendButtonType() { bool HistoryWidget::updateCmdStartShown() { bool cmdStartShown = false; if (_history && _peer && ((_peer->isChat() && _peer->asChat()->botStatus > 0) || (_peer->isMegagroup() && _peer->asChannel()->mgInfo->botStatus > 0) || (_peer->isUser() && _peer->asUser()->isBot()))) { - if (!isBotStart() && !isBlocked() && !_keyboard->hasMarkup() && !_keyboard->forceReply()) { + if (!isBotStart() && !isBlocked() && !_keyboard->hasMarkup() && !_keyboard->forceReply() && !_editMsgId) { if (!HasSendText(_field)) { cmdStartShown = true; } @@ -4081,8 +4078,8 @@ void HistoryWidget::checkFieldAutocomplete() { && cRecentInlineBots().isEmpty()) { session().local().readRecentHashtagsAndBots(); } else if (autocomplete.query[0] == '/' - && _peer->isUser() - && !_peer->asUser()->isBot()) { + && ((_peer->isUser() && !_peer->asUser()->isBot()) + || _editMsgId)) { return; } } @@ -4845,7 +4842,7 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) { _tabbedSelectorToggle->show(); _botKeyboardHide->hide(); _botKeyboardShow->hide(); - _botCommandStart->show(); + _botCommandStart->setVisible(!_editMsgId); } _field->setMaxHeight(computeMaxFieldHeight()); _kbShown = false;