2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Collect local DocumentMedia data.

This commit is contained in:
John Preston
2020-05-22 22:01:04 +04:00
parent 3f26fc9f55
commit 9ce59730ff
5 changed files with 77 additions and 7 deletions

View File

@@ -1621,11 +1621,14 @@ void DocumentData::collectLocalData(not_null<DocumentData*> local) {
}
_owner->cache().copyIfEmpty(local->cacheKey(), cacheKey());
const auto localMedia = local->activeMediaView();
if (!localMedia->bytes().isEmpty()) {
if (const auto media = activeMediaView()) {
media->setBytes(localMedia->bytes());
}
if (const auto localMedia = local->activeMediaView()) {
const auto media = createMediaView();
media->collectLocalData(localMedia.get());
// Keep DocumentMedia alive for some more time.
// NB! This allows DocumentMedia to outlive Main::Session!
// In case this is a problem this code should be rewritten.
crl::on_main(&session(), [media] {});
}
if (!local->_location.inMediaCache() && !local->_location.isEmpty()) {
_location = local->_location;