From c1d3e5f0c5b64316b9a8d34764eddbb6aecf51bd Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 3 Sep 2021 15:48:11 +0300 Subject: [PATCH] Removed sending of typing action when sticker is chose in autocomplete. --- .../SourceFiles/history/history_widget.cpp | 21 ++++++++++--------- Telegram/SourceFiles/history/history_widget.h | 2 +- .../history_view_compose_controls.cpp | 16 +++++++------- .../controls/history_view_compose_controls.h | 2 +- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 476ac5504..12210b96b 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1359,9 +1359,9 @@ void HistoryWidget::orderWidgets() { _attachDragAreas.photo->raise(); } -void HistoryWidget::updateStickersByEmoji() { +bool HistoryWidget::updateStickersByEmoji() { if (!_peer) { - return; + return false; } const auto emoji = [&] { const auto errorForStickers = Data::RestrictionError( @@ -1379,23 +1379,24 @@ void HistoryWidget::updateStickersByEmoji() { return EmojiPtr(nullptr); }(); _fieldAutocomplete->showStickers(emoji); + return (emoji != nullptr); } void HistoryWidget::fieldChanged() { + const auto typing = (_history + && !_inlineBot + && !_editMsgId + && (_textUpdateEvents & TextUpdateEvent::SendTyping)); + InvokeQueued(this, [=] { updateInlineBotQuery(); - updateStickersByEmoji(); - }); - - if (_history) { - if (!_inlineBot - && !_editMsgId - && (_textUpdateEvents & TextUpdateEvent::SendTyping)) { + const auto choosingSticker = updateStickersByEmoji(); + if (!choosingSticker && typing) { session().sendProgressManager().update( _history, Api::SendProgressType::Typing); } - } + }); updateSendButtonType(); if (!HasSendText(_field)) { diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 1a3798080..79db094be 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -154,7 +154,7 @@ public: QRect historyRect() const; void updateFieldPlaceholder(); - void updateStickersByEmoji(); + bool updateStickersByEmoji(); bool confirmSendingFiles(const QStringList &files); bool confirmSendingFiles(not_null data); diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index 8c31ddb1e..124237309 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -1279,9 +1279,9 @@ void ComposeControls::initAutocomplete() { _autocomplete->hideFast(); } -void ComposeControls::updateStickersByEmoji() { +bool ComposeControls::updateStickersByEmoji() { if (!_history) { - return; + return false; } const auto emoji = [&] { const auto errorForStickers = Data::RestrictionError( @@ -1299,6 +1299,7 @@ void ComposeControls::updateStickersByEmoji() { return EmojiPtr(nullptr); }(); _autocomplete->showStickers(emoji); + return (emoji != nullptr); } void ComposeControls::updateFieldPlaceholder() { @@ -1343,11 +1344,9 @@ void ComposeControls::updateSilentBroadcast() { } void ComposeControls::fieldChanged() { - if (!_inlineBot + const auto typing = (!_inlineBot && !_header->isEditingMessage() - && (_textUpdateEvents & TextUpdateEvent::SendTyping)) { - _sendActionUpdates.fire({ Api::SendProgressType::Typing }); - } + && (_textUpdateEvents & TextUpdateEvent::SendTyping)); updateSendButtonType(); if (!HasSendText(_field)) { _previewState = Data::PreviewState::Allowed; @@ -1358,7 +1357,10 @@ void ComposeControls::fieldChanged() { } InvokeQueued(_autocomplete.get(), [=] { updateInlineBotQuery(); - updateStickersByEmoji(); + const auto choosingSticker = updateStickersByEmoji(); + if (!choosingSticker && typing) { + _sendActionUpdates.fire({ Api::SendProgressType::Typing }); + } }); if (!(_textUpdateEvents & TextUpdateEvent::SaveDraft)) { diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h index 60fb7e4cf..8cd5282e0 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h @@ -221,7 +221,7 @@ private: void orderControls(); void checkAutocomplete(); - void updateStickersByEmoji(); + bool updateStickersByEmoji(); void updateFieldPlaceholder(); void updateSilentBroadcast(); void editMessage(not_null item);