| 64 | } |
| 65 | |
| 66 | Image *ReplyPreview::image( |
| 67 | Data::FileOrigin origin, |
| 68 | not_null<PeerData*> context, |
| 69 | bool spoiler) { |
| 70 | auto &image = spoiler ? _spoilered : _regular; |
| 71 | auto &checked = spoiler ? _checkedSpoilered : _checkedRegular; |
| 72 | if (checked) { |
| 73 | return image.get(); |
| 74 | } else if (_document) { |
| 75 | if (!image || (!_good && _document->hasThumbnail())) { |
| 76 | if (!_documentMedia) { |
| 77 | _documentMedia = _document->createMediaView(); |
| 78 | _documentMedia->thumbnailWanted(origin); |
| 79 | } |
| 80 | const auto thumbnail = _documentMedia->thumbnail(); |
| 81 | const auto option = _document->isVideoMessage() |
| 82 | ? Images::Option::RoundCircle |
| 83 | : Images::Option::None; |
| 84 | if (spoiler) { |
| 85 | if (const auto image = _documentMedia->thumbnailInline()) { |
| 86 | prepare(image, option, true); |
| 87 | } else if (thumbnail) { |
| 88 | prepare(thumbnail, option, true); |
| 89 | } |
| 90 | } else if (thumbnail) { |
| 91 | prepare(thumbnail, option); |
| 92 | } else if (!image) { |
| 93 | if (const auto image = _documentMedia->thumbnailInline()) { |
| 94 | prepare(image, option | Images::Option::Blur); |
| 95 | } |
| 96 | } |
| 97 | if (_good || !_document->hasThumbnail()) { |
| 98 | checked = true; |
| 99 | _documentMedia = nullptr; |
| 100 | } |
| 101 | } |
| 102 | } else { |
| 103 | Assert(_photo != nullptr); |
| 104 | if (!image || !_good) { |
| 105 | const auto inlineThumbnailBytes = _photo->inlineThumbnailBytes(); |
| 106 | if (!_photoMedia) { |
| 107 | _photoMedia = _photo->createMediaView(); |
| 108 | } |
| 109 | using Size = PhotoSize; |
| 110 | const auto loadThumbnail = inlineThumbnailBytes.isEmpty() |
| 111 | || (!spoiler |
| 112 | && _photoMedia->autoLoadThumbnailAllowed(context)); |
| 113 | if (loadThumbnail) { |
| 114 | _photoMedia->wanted(Size::Small, origin); |
| 115 | } |
| 116 | if (spoiler) { |
| 117 | if (const auto blurred = _photoMedia->thumbnailInline()) { |
| 118 | prepare(blurred, {}, true); |
| 119 | } else if (const auto small = _photoMedia->image(Size::Small)) { |
| 120 | prepare(small, {}, true); |
| 121 | } else if (const auto large = _photoMedia->image(Size::Large)) { |
| 122 | prepare(large, {}, true); |
| 123 | } |
nothing calls this directly
no test coverage detected