2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Added MEDIA_NEW_INVALID error handler. Disabled edit media with webp.

This commit is contained in:
23rd
2019-04-02 19:24:34 +03:00
parent 92f95fa9eb
commit 84858b8940
2 changed files with 26 additions and 3 deletions

View File

@@ -402,6 +402,16 @@ void EditCaptionBox::createEditMediaButton() {
return;
}
const auto isWebp = [](QString mimeType) {
if (mimeType == qstr("image/webp")) {
Ui::show(
Box<InformBox>(lang(lng_edit_media_album_error)),
LayerOption::KeepOther);
return true;
}
return false;
};
if (!result.remoteContent.isEmpty()) {
// Don't use remoteContent to edit album item.
if (_isAlbum) {
@@ -412,10 +422,16 @@ void EditCaptionBox::createEditMediaButton() {
QString(),
result.remoteContent
).thumbnail;
_preparedList = Storage::PrepareMediaFromImage(
auto list = Storage::PrepareMediaFromImage(
std::move(image),
std::move(result.remoteContent),
st::sendMediaPreviewSize);
if (isWebp(list.files.front().mime)) {
return;
}
_preparedList = std::move(list);
} else if (!result.paths.isEmpty()) {
auto list = Storage::PrepareMediaList(
QStringList(result.paths.front()),
@@ -442,6 +458,11 @@ void EditCaptionBox::createEditMediaButton() {
return;
}
}
const auto info = QFileInfo(result.paths.front());
if (isWebp(Core::MimeTypeForFile(info).name())) {
return;
}
_preparedList = std::move(list);
} else {
return;