From 1a3a0fb124a1e1f77e5b1f6e8149984e91813c89 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 25 Jan 2022 01:07:59 +0300 Subject: [PATCH] Fix caching of webm stickers in local storage. --- Telegram/SourceFiles/data/data_document.cpp | 4 ++++ Telegram/SourceFiles/storage/serialize_document.cpp | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index f61ea0fca..99974e028 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -1400,6 +1400,10 @@ TimeId DocumentData::getDuration() const { return std::max(voice->duration, 0); } else if (isAnimation() || isVideoFile()) { return std::max(_duration, 0); + } else if (const auto sticker = this->sticker()) { + if (sticker->isWebm()) { + return std::max(_duration, 0); + } } return -1; } diff --git a/Telegram/SourceFiles/storage/serialize_document.cpp b/Telegram/SourceFiles/storage/serialize_document.cpp index 4492b7bf6..50e4c51ac 100644 --- a/Telegram/SourceFiles/storage/serialize_document.cpp +++ b/Telegram/SourceFiles/storage/serialize_document.cpp @@ -18,7 +18,7 @@ namespace Serialize { namespace { constexpr auto kVersionTag = int32(0x7FFFFFFF); -constexpr auto kVersion = 2; +constexpr auto kVersion = 3; enum StickerSetType { StickerSetTypeEmpty = 0, @@ -43,9 +43,8 @@ void Document::writeToStream(QDataStream &stream, DocumentData *document) { } else { stream << qint32(StickerSetTypeEmpty); } - } else { - stream << qint32(document->getDuration()); } + stream << qint32(document->getDuration()); writeImageLocation(stream, document->thumbnailLocation()); stream << qint32(document->thumbnailByteSize()); writeImageLocation(stream, document->videoThumbnailLocation()); @@ -115,6 +114,9 @@ DocumentData *Document::readFromStreamHelper( } break; } } + if (version >= 3) { + stream >> duration; + } } else { stream >> duration; if (type == AnimatedDocument) {