2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Moved searching of sticker mimes to single place.

This commit is contained in:
23rd
2020-01-07 13:41:13 +03:00
committed by John Preston
parent f3595e379c
commit d1d5312ead
7 changed files with 17 additions and 20 deletions

View File

@@ -656,9 +656,6 @@ bool FileLoadTask::FillImageInformation(
}
void FileLoadTask::process() {
const auto stickerMime = qsl("image/webp");
const auto animatedStickerMime = qsl("application/x-tgsticker");
_result = std::make_shared<FileLoadResult>(
id(),
_id,
@@ -700,7 +697,7 @@ void FileLoadTask::process() {
if (auto image = base::get_if<FileMediaInformation::Image>(
&_information->media)) {
fullimage = base::take(image->data);
if (filemime != stickerMime && filemime != animatedStickerMime) {
if (!Core::IsMimeSticker(filemime)) {
fullimage = Images::prepareOpaque(std::move(fullimage));
}
isAnimation = image->animated;
@@ -719,7 +716,7 @@ void FileLoadTask::process() {
}
const auto mimeType = Core::MimeTypeForData(_content);
filemime = mimeType.name();
if (filemime != stickerMime && filemime != animatedStickerMime) {
if (!Core::IsMimeSticker(filemime)) {
fullimage = Images::prepareOpaque(std::move(fullimage));
}
if (filemime == "image/jpeg") {
@@ -831,8 +828,7 @@ void FileLoadTask::process() {
attributes.push_back(MTP_documentAttributeImageSize(MTP_int(w), MTP_int(h)));
if (ValidateThumbDimensions(w, h)) {
isSticker = (filemime == stickerMime
|| filemime == animatedStickerMime)
isSticker = Core::IsMimeSticker(filemime)
&& (w > 0)
&& (h > 0)
&& (w <= StickerMaxSize)

View File

@@ -34,9 +34,7 @@ bool HasExtensionFrom(const QString &file, const QStringList &extensions) {
bool ValidPhotoForAlbum(
const FileMediaInformation::Image &image,
const QString &mime) {
if (image.animated
|| mime == qstr("image/webp")
|| mime == qstr("application/x-tgsticker")) {
if (image.animated || Core::IsMimeSticker(mime)) {
return false;
}
const auto width = image.data.width();
@@ -397,7 +395,7 @@ bool PreparedList::canAddCaption(bool isAlbum, bool compressImages) const {
if (files.empty()) {
return false;
}
return (files.front().mime == qstr("image/webp"))
return Core::IsMimeSticker(files.front().mime)
|| files.front().path.endsWith(
qstr(".tgs"),
Qt::CaseInsensitive);