2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Keep document byte data only in DocumentMedia.

This commit is contained in:
John Preston
2020-04-10 17:18:51 +04:00
parent 97bab388ea
commit 40f12a2584
26 changed files with 280 additions and 241 deletions

View File

@@ -1028,15 +1028,13 @@ void GifsListWidget::showPreview() {
auto layout = _rows[row].items[col];
if (const auto w = App::wnd()) {
if (const auto previewDocument = layout->getPreviewDocument()) {
w->showMediaPreview(
_previewShown = w->showMediaPreview(
Data::FileOriginSavedGifs(),
previewDocument);
_previewShown = true;
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
w->showMediaPreview(
_previewShown = w->showMediaPreview(
Data::FileOrigin(),
previewPhoto);
_previewShown = true;
}
}
}

View File

@@ -1220,7 +1220,8 @@ not_null<Lottie::Animation*> LottieAnimationFromDocument(
bool HasLottieThumbnail(
ImagePtr thumbnail,
not_null<DocumentData*> sticker) {
not_null<Data::DocumentMedia*> media) {
const auto document = media->owner();
if (thumbnail) {
if (!thumbnail->loaded()) {
return false;
@@ -1230,15 +1231,15 @@ bool HasLottieThumbnail(
return location.valid()
&& location.type() == StorageFileLocation::Type::StickerSetThumb
&& !bytes.isEmpty();
} else if (const auto info = sticker->sticker()) {
} else if (const auto info = document->sticker()) {
if (!info->animated) {
return false;
}
sticker->automaticLoad(sticker->stickerSetOrigin(), nullptr);
if (!sticker->loaded()) {
document->automaticLoad(document->stickerSetOrigin(), nullptr);
if (!media->loaded()) {
return false;
}
return sticker->bigFileBaseCacheKey().has_value();
return document->bigFileBaseCacheKey().has_value();
}
return false;
}

View File

@@ -160,7 +160,7 @@ enum class LottieSize : uchar {
[[nodiscard]] bool HasLottieThumbnail(
ImagePtr thumbnail,
not_null<DocumentData*> sticker);
not_null<Data::DocumentMedia*> media);
[[nodiscard]] std::unique_ptr<Lottie::SinglePlayer> LottieThumbnail(
ImagePtr thumbnail,
not_null<Data::DocumentMedia*> media,

View File

@@ -701,7 +701,9 @@ void StickersListWidget::Footer::paintSearchIcon(Painter &p) const {
void StickersListWidget::Footer::validateIconLottieAnimation(
const StickerIcon &icon) {
if (icon.lottie
|| !Stickers::HasLottieThumbnail(icon.thumbnail, icon.sticker)) {
|| !Stickers::HasLottieThumbnail(
icon.thumbnail,
icon.stickerMedia.get())) {
return;
}
auto player = Stickers::LottieThumbnail(