Update video qualities list.

This commit is contained in:
John Preston 2024-11-24 17:51:12 +04:00
parent 475dec3014
commit e52baf555f
3 changed files with 37 additions and 0 deletions

View file

@ -451,6 +451,9 @@ not_null<HistoryItem*> History::createItem(
if (detachExistingItem) {
result->removeMainView();
}
if (result->needsUpdateForVideoQualities(message)) {
owner().updateEditedMessage(message);
}
return result;
}
const auto result = message.match([&](const auto &data) {

View file

@ -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);

View file

@ -553,6 +553,8 @@ public:
[[nodiscard]] bool canUpdateDate() const;
void customEmojiRepaint();
[[nodiscard]] bool needsUpdateForVideoQualities(const MTPMessage &data);
[[nodiscard]] TimeId ttlDestroyAt() const {
return _ttlDestroyAt;
}