diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index a88097c104..c5c4402ee8 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -4639,6 +4639,7 @@ void ApiWrap::editUploadedPhoto( sentEntities )).done([=](const MTPUpdates &result) { item->clearSavedMedia(); + item->setIsLocalUpdateMedia(true); applyUpdates(result); }).fail([=](const RPCError &error) { QString err = error.type(); @@ -4702,6 +4703,7 @@ void ApiWrap::editUploadedDocument( sentEntities )).done([=](const MTPUpdates &result) { item->clearSavedMedia(); + item->setIsLocalUpdateMedia(true); applyUpdates(result); }).fail([=](const RPCError &error) { QString err = error.type(); diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 16f7ac0d68..d7faa350f7 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -159,9 +159,9 @@ namespace App { return false; } - void updateEditedMessage(const MTPMessage &message) { - message.match([](const MTPDmessageEmpty &) { - }, [](const auto &message) { + void updateEditedMessage(const MTPMessage &m) { + m.match([](const MTPDmessageEmpty &) { + }, [&m](const auto &message) { auto peerId = peerFromMTP(message.vto_id); if (message.has_from_id() && peerId == Auth().userPeerId()) { peerId = peerFromUser(message.vfrom_id); @@ -170,7 +170,16 @@ namespace App { peerToChannel(peerId), message.vid.v); if (existing) { - existing->applyEdition(message); + auto update = true; + if (existing->isLocalUpdateMedia()) { + if (checkEntitiesAndViewsUpdate(m.c_message())) { + update = false; + existing->setIsLocalUpdateMedia(false); + } + } + if (update) { + existing->applyEdition(message); + } } }); } diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 3a693ef1d6..3980c61261 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -130,6 +130,13 @@ public: _isEditingMedia = edit; } + bool isLocalUpdateMedia() const { + return _isLocalUpdateMedia; + } + void setIsLocalUpdateMedia(bool flag) { + _isLocalUpdateMedia = flag; + } + // For edit media in history_message. virtual void returnSavedMedia() {}; void clearSavedMedia() { @@ -326,6 +333,7 @@ protected: int _textHeight = 0; bool _isEditingMedia = false; + bool _isLocalUpdateMedia = false; std::unique_ptr _savedMedia; std::unique_ptr _media;