mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-02 23:45:44 +00:00
Support different location types for thumbnails.
This commit is contained in:
@@ -13,6 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_document_media.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_session.h"
|
||||
#include "ui/image/image_location_factory.h"
|
||||
#include "core/mime_type.h"
|
||||
#include "main/main_session.h"
|
||||
|
||||
namespace Storage {
|
||||
@@ -44,6 +46,10 @@ constexpr auto kUploadRequestInterval = crl::time(500);
|
||||
// How much time without upload causes additional session kill.
|
||||
constexpr auto kKillSessionTimeout = 15 * crl::time(000);
|
||||
|
||||
[[nodiscard]] const char *ThumbnailFormat(const QString &mime) {
|
||||
return Core::IsMimeSticker(mime) ? "WEBP" : "JPG";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
struct Uploader::File {
|
||||
@@ -160,7 +166,9 @@ void Uploader::uploadMedia(
|
||||
? Auth().data().processDocument(media.document)
|
||||
: Auth().data().processDocument(
|
||||
media.document,
|
||||
base::duplicate(media.photoThumbs.front().second));
|
||||
Images::FromImageInMemory(
|
||||
media.photoThumbs.front().second,
|
||||
"JPG"));
|
||||
if (!media.data.isEmpty()) {
|
||||
document->setDataAndCache(media.data);
|
||||
if (media.type == SendMediaType::ThemeFile) {
|
||||
@@ -191,13 +199,18 @@ void Uploader::upload(
|
||||
? Auth().data().processDocument(file->document)
|
||||
: Auth().data().processDocument(
|
||||
file->document,
|
||||
std::move(file->thumb));
|
||||
Images::FromImageInMemory(
|
||||
file->thumb,
|
||||
ThumbnailFormat(file->filemime)));
|
||||
document->uploadingData = std::make_unique<Data::UploadState>(
|
||||
document->size);
|
||||
if (!file->goodThumbnail.isNull()) {
|
||||
if (const auto active = document->activeMediaView()) {
|
||||
if (const auto active = document->activeMediaView()) {
|
||||
if (!file->goodThumbnail.isNull()) {
|
||||
active->setGoodThumbnail(std::move(file->goodThumbnail));
|
||||
}
|
||||
if (!file->thumb.isNull()) {
|
||||
active->setThumbnail(file->thumb);
|
||||
}
|
||||
}
|
||||
if (!file->goodThumbnailBytes.isEmpty()) {
|
||||
document->owner().cache().putIfEmpty(
|
||||
@@ -208,13 +221,13 @@ void Uploader::upload(
|
||||
}
|
||||
if (!file->content.isEmpty()) {
|
||||
document->setDataAndCache(file->content);
|
||||
if (file->type == SendMediaType::ThemeFile) {
|
||||
document->checkWallPaperProperties();
|
||||
}
|
||||
}
|
||||
if (!file->filepath.isEmpty()) {
|
||||
document->setLocation(FileLocation(file->filepath));
|
||||
}
|
||||
if (file->type == SendMediaType::ThemeFile) {
|
||||
document->checkWallPaperProperties();
|
||||
}
|
||||
}
|
||||
queue.emplace(msgId, File(file));
|
||||
sendNext();
|
||||
|
Reference in New Issue
Block a user