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

Added ability to edit GIFs.

- Added to Media::Clip::MakeReader new constructor to create
 animated preview with remoteContent.
This commit is contained in:
23rd
2019-04-08 21:13:18 +03:00
committed by John Preston
parent 49681525ed
commit fb847135b5
5 changed files with 78 additions and 31 deletions

View File

@@ -4659,6 +4659,9 @@ void ApiWrap::editUploadedFile(
if (!item) {
return;
}
if (!item->media()) {
return;
}
auto sentEntities = TextUtilities::EntitiesToMTP(
item->originalText().entities,
@@ -4669,21 +4672,31 @@ void ApiWrap::editUploadedFile(
flagsEditMsg |= MTPmessages_EditMessage::Flag::f_entities;
flagsEditMsg |= MTPmessages_EditMessage::Flag::f_media;
MTPinputMedia media = MTP_inputMediaEmpty();
const auto media = [&]() -> std::optional<MTPInputMedia> {
if (!isDocument) {
if (!item->media()->photo()) {
return std::nullopt;
}
return MTP_inputMediaUploadedPhoto(
MTP_flags(0),
file,
MTPVector<MTPInputDocument>(),
MTP_int(0));
}
if (isDocument) {
const auto document = item->media()->document();
if (!document) {
return;
return std::nullopt;
}
const auto flags = MTPDinputMediaUploadedDocument::Flags(0)
| (thumb
? MTPDinputMediaUploadedDocument::Flag::f_thumb
: MTPDinputMediaUploadedDocument::Flag(0))
// Never edit video as gif.
| MTPDinputMediaUploadedDocument::Flag::f_nosound_video;
media = MTP_inputMediaUploadedDocument(
| (item->groupId()
? MTPDinputMediaUploadedDocument::Flag::f_nosound_video
: MTPDinputMediaUploadedDocument::Flag(0));
return MTP_inputMediaUploadedDocument(
MTP_flags(flags),
file,
thumb ? *thumb : MTPInputFile(),
@@ -4691,16 +4704,10 @@ void ApiWrap::editUploadedFile(
ComposeSendingDocumentAttributes(document),
MTPVector<MTPInputDocument>(),
MTP_int(0));
} else {
const auto photo = item->media()->photo();
if (!photo) {
return;
}
media = MTP_inputMediaUploadedPhoto(
MTP_flags(0),
file,
MTPVector<MTPInputDocument>(),
MTP_int(0));
}();
if (!media) {
return;
}
request(MTPmessages_EditMessage(
@@ -4708,7 +4715,7 @@ void ApiWrap::editUploadedFile(
item->history()->peer->input,
MTP_int(item->id),
MTP_string(item->originalText().text),
media,
*media,
MTPReplyMarkup(),
sentEntities
)).done([=](const MTPUpdates &result) {