Hide bot command start button when editing message.

Fixes #9941.
This commit is contained in:
John Preston 2020-12-30 16:27:32 +04:00
parent 818624e051
commit 3fd62d51aa

View file

@ -1661,6 +1661,7 @@ void HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) {
_editMsgId = 0; _editMsgId = 0;
_replyToId = readyToForward() ? 0 : _history->localDraft()->msgId; _replyToId = readyToForward() ? 0 : _history->localDraft()->msgId;
} }
updateCmdStartShown();
updateControlsVisibility(); updateControlsVisibility();
updateControlsGeometry(); updateControlsGeometry();
refreshTopBarActiveChat(); refreshTopBarActiveChat();
@ -2228,11 +2229,7 @@ void HistoryWidget::updateControlsVisibility() {
_botCommandStart->hide(); _botCommandStart->hide();
} else { } else {
_botKeyboardShow->hide(); _botKeyboardShow->hide();
if (_cmdStartShown) { _botCommandStart->setVisible(_cmdStartShown);
_botCommandStart->show();
} else {
_botCommandStart->hide();
}
} }
} }
_attachToggle->show(); _attachToggle->show();
@ -3738,7 +3735,7 @@ void HistoryWidget::updateSendButtonType() {
bool HistoryWidget::updateCmdStartShown() { bool HistoryWidget::updateCmdStartShown() {
bool cmdStartShown = false; 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 (_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)) { if (!HasSendText(_field)) {
cmdStartShown = true; cmdStartShown = true;
} }
@ -4081,8 +4078,8 @@ void HistoryWidget::checkFieldAutocomplete() {
&& cRecentInlineBots().isEmpty()) { && cRecentInlineBots().isEmpty()) {
session().local().readRecentHashtagsAndBots(); session().local().readRecentHashtagsAndBots();
} else if (autocomplete.query[0] == '/' } else if (autocomplete.query[0] == '/'
&& _peer->isUser() && ((_peer->isUser() && !_peer->asUser()->isBot())
&& !_peer->asUser()->isBot()) { || _editMsgId)) {
return; return;
} }
} }
@ -4845,7 +4842,7 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
_tabbedSelectorToggle->show(); _tabbedSelectorToggle->show();
_botKeyboardHide->hide(); _botKeyboardHide->hide();
_botKeyboardShow->hide(); _botKeyboardShow->hide();
_botCommandStart->show(); _botCommandStart->setVisible(!_editMsgId);
} }
_field->setMaxHeight(computeMaxFieldHeight()); _field->setMaxHeight(computeMaxFieldHeight());
_kbShown = false; _kbShown = false;