2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-04 16:35:44 +00:00

Clear DocumentMedia in ReplyPreview.

This commit is contained in:
John Preston
2020-05-21 15:40:10 +04:00
parent 44ec55b6a8
commit d64014c995
4 changed files with 22 additions and 8 deletions

View File

@@ -17,8 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Data {
ReplyPreview::ReplyPreview(not_null<DocumentData*> document)
: _document(document)
, _documentMedia(_document->createMediaView()) {
: _document(document) {
}
ReplyPreview::ReplyPreview(not_null<PhotoData*> photo)
@@ -59,7 +58,13 @@ void ReplyPreview::prepare(not_null<Image*> image, Images::Options options) {
}
Image *ReplyPreview::image(Data::FileOrigin origin) {
if (_checked) {
return _image.get();
}
if (_document) {
if (!_documentMedia) {
_documentMedia = _document->createMediaView();
}
const auto thumbnail = _documentMedia->thumbnail();
if (!_image || (!_good && thumbnail)) {
const auto option = _document->isVideoMessage()
@@ -73,6 +78,10 @@ Image *ReplyPreview::image(Data::FileOrigin origin) {
prepare(image, option | Images::Option::Blurred);
}
}
if (thumbnail || !_document->hasThumbnail()) {
_checked = true;
_documentMedia = nullptr;
}
}
} else {
Assert(_photo != nullptr);