Fix caching of webm stickers in local storage.

This commit is contained in:
John Preston 2022-01-25 01:07:59 +03:00
parent f1d9cca119
commit 1a3a0fb124
2 changed files with 9 additions and 3 deletions

View file

@ -1400,6 +1400,10 @@ TimeId DocumentData::getDuration() const {
return std::max(voice->duration, 0); return std::max(voice->duration, 0);
} else if (isAnimation() || isVideoFile()) { } else if (isAnimation() || isVideoFile()) {
return std::max(_duration, 0); return std::max(_duration, 0);
} else if (const auto sticker = this->sticker()) {
if (sticker->isWebm()) {
return std::max(_duration, 0);
}
} }
return -1; return -1;
} }

View file

@ -18,7 +18,7 @@ namespace Serialize {
namespace { namespace {
constexpr auto kVersionTag = int32(0x7FFFFFFF); constexpr auto kVersionTag = int32(0x7FFFFFFF);
constexpr auto kVersion = 2; constexpr auto kVersion = 3;
enum StickerSetType { enum StickerSetType {
StickerSetTypeEmpty = 0, StickerSetTypeEmpty = 0,
@ -43,9 +43,8 @@ void Document::writeToStream(QDataStream &stream, DocumentData *document) {
} else { } else {
stream << qint32(StickerSetTypeEmpty); stream << qint32(StickerSetTypeEmpty);
} }
} else {
stream << qint32(document->getDuration());
} }
stream << qint32(document->getDuration());
writeImageLocation(stream, document->thumbnailLocation()); writeImageLocation(stream, document->thumbnailLocation());
stream << qint32(document->thumbnailByteSize()); stream << qint32(document->thumbnailByteSize());
writeImageLocation(stream, document->videoThumbnailLocation()); writeImageLocation(stream, document->videoThumbnailLocation());
@ -115,6 +114,9 @@ DocumentData *Document::readFromStreamHelper(
} break; } break;
} }
} }
if (version >= 3) {
stream >> duration;
}
} else { } else {
stream >> duration; stream >> duration;
if (type == AnimatedDocument) { if (type == AnimatedDocument) {