mirror of https://github.com/procxx/kepka.git
Added MEDIA_NEW_INVALID error handler. Disabled edit media with webp.
This commit is contained in:
parent
92f95fa9eb
commit
84858b8940
|
@ -4644,7 +4644,8 @@ void ApiWrap::editUploadedPhoto(
|
||||||
applyUpdates(result);
|
applyUpdates(result);
|
||||||
}).fail([=](const RPCError &error) {
|
}).fail([=](const RPCError &error) {
|
||||||
QString err = error.type();
|
QString err = error.type();
|
||||||
if (err == qstr("MESSAGE_NOT_MODIFIED")) {
|
if (err == qstr("MESSAGE_NOT_MODIFIED")
|
||||||
|
|| err == qstr("MEDIA_NEW_INVALID")) {
|
||||||
item->returnSavedMedia();
|
item->returnSavedMedia();
|
||||||
_session->data().sendHistoryChangeNotifications();
|
_session->data().sendHistoryChangeNotifications();
|
||||||
} else {
|
} else {
|
||||||
|
@ -4707,7 +4708,8 @@ void ApiWrap::editUploadedDocument(
|
||||||
applyUpdates(result);
|
applyUpdates(result);
|
||||||
}).fail([=](const RPCError &error) {
|
}).fail([=](const RPCError &error) {
|
||||||
QString err = error.type();
|
QString err = error.type();
|
||||||
if (err == qstr("MESSAGE_NOT_MODIFIED")) {
|
if (err == qstr("MESSAGE_NOT_MODIFIED")
|
||||||
|
|| err == qstr("MEDIA_NEW_INVALID")) {
|
||||||
item->returnSavedMedia();
|
item->returnSavedMedia();
|
||||||
_session->data().sendHistoryChangeNotifications();
|
_session->data().sendHistoryChangeNotifications();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -402,6 +402,16 @@ void EditCaptionBox::createEditMediaButton() {
|
||||||
return;
|
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()) {
|
if (!result.remoteContent.isEmpty()) {
|
||||||
// Don't use remoteContent to edit album item.
|
// Don't use remoteContent to edit album item.
|
||||||
if (_isAlbum) {
|
if (_isAlbum) {
|
||||||
|
@ -412,10 +422,16 @@ void EditCaptionBox::createEditMediaButton() {
|
||||||
QString(),
|
QString(),
|
||||||
result.remoteContent
|
result.remoteContent
|
||||||
).thumbnail;
|
).thumbnail;
|
||||||
_preparedList = Storage::PrepareMediaFromImage(
|
auto list = Storage::PrepareMediaFromImage(
|
||||||
std::move(image),
|
std::move(image),
|
||||||
std::move(result.remoteContent),
|
std::move(result.remoteContent),
|
||||||
st::sendMediaPreviewSize);
|
st::sendMediaPreviewSize);
|
||||||
|
|
||||||
|
if (isWebp(list.files.front().mime)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_preparedList = std::move(list);
|
||||||
} else if (!result.paths.isEmpty()) {
|
} else if (!result.paths.isEmpty()) {
|
||||||
auto list = Storage::PrepareMediaList(
|
auto list = Storage::PrepareMediaList(
|
||||||
QStringList(result.paths.front()),
|
QStringList(result.paths.front()),
|
||||||
|
@ -442,6 +458,11 @@ void EditCaptionBox::createEditMediaButton() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const auto info = QFileInfo(result.paths.front());
|
||||||
|
if (isWebp(Core::MimeTypeForFile(info).name())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_preparedList = std::move(list);
|
_preparedList = std::move(list);
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue