diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 8c9be9ce7..7f47ffe06 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -451,6 +451,9 @@ not_null History::createItem( if (detachExistingItem) { result->removeMainView(); } + if (result->needsUpdateForVideoQualities(message)) { + owner().updateEditedMessage(message); + } return result; } const auto result = message.match([&](const auto &data) { diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index a63b7b6c3..cc757bcd9 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -1303,6 +1303,38 @@ void HistoryItem::customEmojiRepaint() { } } +bool HistoryItem::needsUpdateForVideoQualities(const MTPMessage &data) { + // When video gets the converted alt-videos lists, we need to update + // the message data even without edit-message update. + return data.match([&](const MTPDmessage &data) { + const auto media = data.vmedia(); + if (!media) { + return false; + } + return media->match([&](const MTPDmessageMediaDocument &data) { + const auto document = data.vdocument(); + const auto alts = data.valt_documents(); + if (!document || !alts || alts->v.isEmpty()) { + return false; + } + const auto id = document->match([](const auto &data) { + return DocumentId(data.vid().v); + }); + const auto existingMedia = this->media(); + const auto existingDocument = existingMedia + ? existingMedia->document() + : nullptr; + return !existingDocument + || (existingDocument->id != id) + || existingDocument->resolveQualities(this).empty(); + }, [](const auto &) { + return false; + }); + }, [](const auto &) { + return false; + }); +} + void HistoryItem::finishEditionToEmpty() { finishEdition(-1); _history->itemVanished(this); diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 9a17be15f..ac24b011a 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -553,6 +553,8 @@ public: [[nodiscard]] bool canUpdateDate() const; void customEmojiRepaint(); + [[nodiscard]] bool needsUpdateForVideoQualities(const MTPMessage &data); + [[nodiscard]] TimeId ttlDestroyAt() const { return _ttlDestroyAt; }