diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index 994b0e6fa0..4491dd8b6b 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/platform_specific.h" #include "history/history.h" #include "history/history_item.h" +#include "history/view/media/history_view_gif.h" #include "window/window_session_controller.h" #include "storage/cache/storage_cache_database.h" #include "boxes/confirm_box.h" @@ -340,7 +341,9 @@ void DocumentOpenClickHandler::Open( || data->isVideoMessage()) { const auto msgId = context ? context->fullId() : FullMsgId(); Media::Player::instance()->playPause({ data, msgId }); - } else if (context && data->isAnimation()) { + } else if (context + && data->isAnimation() + && HistoryView::Gif::CanPlayInline(data)) { data->owner().requestAnimationPlayInline(context); } else { Core::App().showDocument(data, context); diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index c73ac810cf..43658fda85 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -50,11 +50,6 @@ int gifMaxStatusWidth(DocumentData *document) { return result; } -[[nodiscard]] bool CanPlayInline(not_null document) { - const auto dimensions = document->dimensions; - return dimensions.width() * dimensions.height() <= kMaxInlineArea; -} - } // namespace struct Gif::Streamed { @@ -109,6 +104,11 @@ Gif::~Gif() { } } +bool Gif::CanPlayInline(not_null document) { + const auto dimensions = document->dimensions; + return dimensions.width() * dimensions.height() <= kMaxInlineArea; +} + QSize Gif::sizeForAspectRatio() const { // We use size only for aspect ratio and we want to have it // as close to the thumbnail as possible. diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.h b/Telegram/SourceFiles/history/view/media/history_view_gif.h index 4ac8342a5b..31a32b94d5 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.h +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.h @@ -110,6 +110,8 @@ public: void refreshParentId(not_null realParent) override; + [[nodiscard]] static bool CanPlayInline(not_null document); + private: struct Streamed;