diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index 00483372c..ee0963a39 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -1103,6 +1103,7 @@ bool FieldAutocomplete::Inner::chooseAtIndex( stickerBoundingBox())); contentRect.moveCenter(bounding.center()); return { + Ui::MessageSendingAnimationFrom::Type::Sticker, _controller->session().data().nextLocalMessageId(), mapToGlobal(std::move(contentRect)), }; diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index ae171bbe1..c33526b2f 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -447,6 +447,7 @@ void GifsListWidget::selectInlineResult( const auto rect = item->innerContentRect().translated( _mosaic.findRect(index).topLeft()); return Ui::MessageSendingAnimationFrom{ + .type = Ui::MessageSendingAnimationFrom::Type::Gif, .localId = controller()->session().data().nextLocalMessageId(), .globalStartGeometry = mapToGlobal(rect), .crop = true, diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index a444240fc..aed37ae48 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -2529,6 +2529,7 @@ Ui::MessageSendingAnimationFrom StickersListWidget::messageSentAnimationInfo( (rect.height() - size.height()) / 2); return { + .type = Ui::MessageSendingAnimationFrom::Type::Sticker, .localId = session().data().nextLocalMessageId(), .globalStartGeometry = mapToGlobal( QRect(rect.topLeft() + innerPos, size)), diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 870c26cef..5041c72dc 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -5391,7 +5391,8 @@ void HistoryWidget::startItemRevealAnimations() { void HistoryWidget::startMessageSendingAnimation( not_null item) { auto &sendingAnimation = controller()->sendingAnimation(); - if (!sendingAnimation.hasLocalMessage(item->fullId().msg)) { + if (!sendingAnimation.hasLocalMessage(item->fullId().msg) + || !sendingAnimation.checkExpectedType(item)) { return; } Assert(item->mainView() != nullptr); diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index a8b9ba2cc..481c88e85 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -1581,7 +1581,8 @@ void ListWidget::startItemRevealAnimations() { void ListWidget::startMessageSendingAnimation( not_null item) { auto &sendingAnimation = controller()->sendingAnimation(); - if (!sendingAnimation.hasLocalMessage(item->fullId().msg)) { + if (!sendingAnimation.hasLocalMessage(item->fullId().msg) + || !sendingAnimation.checkExpectedType(item)) { return; } diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.h b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.h index 4914ca234..0b6f02a9b 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.h +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.h @@ -73,9 +73,6 @@ public: bool hasRightSkip() const override { return true; } - bool hasSendingAnimation() const override { - return true; - } void paint(Painter &p, const QRect &clip, const PaintContext *context) const override; TextState getState( @@ -194,9 +191,6 @@ public: bool hasRightSkip() const override { return false; } - bool hasSendingAnimation() const override { - return true; - } void preload() const override; void paint(Painter &p, const QRect &clip, const PaintContext *context) const override; diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h index 7c472aee4..d989bc91c 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h @@ -83,9 +83,6 @@ public: virtual bool hasRightSkip() const { return false; } - virtual bool hasSendingAnimation() const { - return false; - } Result *getResult() const; DocumentData *getDocument() const; diff --git a/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp b/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp index e104e3fa4..f5576383f 100644 --- a/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp @@ -270,12 +270,22 @@ void Inner::selectInlineResult( const auto document = item->getDocument() ? item->getDocument() : item->getPreviewDocument(); - if (options.scheduled || !item->hasSendingAnimation()) { + if (options.scheduled + || item->isFullLine() + || !document + || (!document->sticker() && !document->isGifv())) { return {}; } + using Type = Ui::MessageSendingAnimationFrom::Type; + const auto type = document->sticker() + ? Type::Sticker + : document->isGifv() + ? Type::Gif + : Type::None; const auto rect = item->innerContentRect().translated( _mosaic.findRect(index).topLeft()); return { + .type = type, .localId = _controller->session().data().nextLocalMessageId(), .globalStartGeometry = mapToGlobal(rect), .crop = document->isGifv(), diff --git a/Telegram/SourceFiles/ui/effects/message_sending_animation_common.h b/Telegram/SourceFiles/ui/effects/message_sending_animation_common.h index 7f9e26429..c2faaeb4c 100644 --- a/Telegram/SourceFiles/ui/effects/message_sending_animation_common.h +++ b/Telegram/SourceFiles/ui/effects/message_sending_animation_common.h @@ -10,6 +10,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Ui { struct MessageSendingAnimationFrom { + enum class Type { + None, + Sticker, + Gif, + }; + Type type = Type::None; std::optional localId; QRect globalStartGeometry; bool crop = false; diff --git a/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.cpp b/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.cpp index c4bbeec7b..1305f8b2f 100644 --- a/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.cpp +++ b/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "ui/effects/message_sending_animation_controller.h" +#include "data/data_document.h" #include "data/data_session.h" #include "history/history_item.h" #include "history/view/history_view_element.h" @@ -417,4 +418,29 @@ void MessageSendingAnimationController::clear() { _processing.clear(); } +bool MessageSendingAnimationController::checkExpectedType( + not_null item) { + const auto it = _itemSendPending.find(item->fullId().msg); + if (it == end(_itemSendPending)) { + return false; + } + const auto type = it->second.type; + const auto isSticker = type == MessageSendingAnimationFrom::Type::Sticker; + const auto isGif = type == MessageSendingAnimationFrom::Type::Gif; + if (isSticker || isGif) { + if (item->emptyText()) { + if (const auto media = item->media()) { + if (const auto document = media->document()) { + if ((isGif && document->isGifv()) + || (isSticker && document->sticker())) { + return true; + } + } + } + } + } + _itemSendPending.erase(it); + return false; +} + } // namespace Ui diff --git a/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.h b/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.h index 8c46428a6..92bb9a915 100644 --- a/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.h +++ b/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.h @@ -39,6 +39,7 @@ public: [[nodiscard]] bool hasLocalMessage(MsgId msgId) const; [[nodiscard]] bool hasAnimatedMessage(not_null item) const; + [[nodiscard]] bool checkExpectedType(not_null item); void clear();