diff --git a/Telegram/SourceFiles/history/media/history_media_sticker.cpp b/Telegram/SourceFiles/history/media/history_media_sticker.cpp index 4c5d3aa11..3e132bcea 100644 --- a/Telegram/SourceFiles/history/media/history_media_sticker.cpp +++ b/Telegram/SourceFiles/history/media/history_media_sticker.cpp @@ -94,10 +94,14 @@ QSize HistorySticker::countCurrentSize(int newWidth) { } void HistorySticker::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { - if (!_lottie - && _data->loaded() - && Lottie::ValidateFile(_data->filepath())) { - _lottie = Lottie::FromFile(_data->filepath()); + if (!_lottie && _data->filename().endsWith(qstr(".json"))) { + if (_data->loaded()) { + _lottie = _data->data().isEmpty() + ? Lottie::FromFile(_data->filepath()) + : Lottie::FromData(_data->data()); + } else { + _data->automaticLoad(_parent->data()->fullId(), _parent->data()); + } } auto sticker = _data->sticker(); diff --git a/Telegram/SourceFiles/lottie/lottie_animation.cpp b/Telegram/SourceFiles/lottie/lottie_animation.cpp index 29f53d9e5..be39d3830 100644 --- a/Telegram/SourceFiles/lottie/lottie_animation.cpp +++ b/Telegram/SourceFiles/lottie/lottie_animation.cpp @@ -51,7 +51,11 @@ std::unique_ptr FromFile(const QString &path) { if (content.isEmpty()) { return nullptr; } - return std::make_unique(content); + return FromData(content); +} + +std::unique_ptr FromData(const QByteArray &data) { + return std::make_unique(data); } Animation::Animation(const QByteArray &content) { diff --git a/Telegram/SourceFiles/lottie/lottie_animation.h b/Telegram/SourceFiles/lottie/lottie_animation.h index f960ccc0f..999b4a8d1 100644 --- a/Telegram/SourceFiles/lottie/lottie_animation.h +++ b/Telegram/SourceFiles/lottie/lottie_animation.h @@ -25,6 +25,7 @@ class Animation; bool ValidateFile(const QString &path); std::unique_ptr FromFile(const QString &path); +std::unique_ptr FromData(const QByteArray &data); struct PlaybackOptions { float64 speed = 1.;