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

Improve video userpics in chat history.

This commit is contained in:
John Preston
2020-07-03 22:57:30 +04:00
parent f99960e1f6
commit 5c5414b680
6 changed files with 157 additions and 48 deletions

View File

@@ -309,6 +309,18 @@ bool ShouldAutoPlay(
document->size);
}
bool ShouldAutoPlay(
const Full &data,
not_null<PeerData*> peer,
not_null<PhotoData*> photo) {
const auto source = SourceFromPeer(peer);
const auto size = photo->videoByteSize();
return photo->hasVideo()
&& (data.shouldDownload(source, Type::AutoPlayGIF, size)
|| data.shouldDownload(source, Type::AutoPlayVideo, size)
|| data.shouldDownload(source, Type::AutoPlayVideoMessage, size));
}
Full WithDisabledAutoPlay(const Full &data) {
auto result = data;
for (const auto source : enums_view<Source>(kSourcesCount)) {

View File

@@ -120,6 +120,10 @@ private:
const Full &data,
not_null<PeerData*> peer,
not_null<DocumentData*> document);
[[nodiscard]] bool ShouldAutoPlay(
const Full &data,
not_null<PeerData*> peer,
not_null<PhotoData*> photo);
[[nodiscard]] Full WithDisabledAutoPlay(const Full &data);

View File

@@ -3208,6 +3208,10 @@ void Session::checkPlayingAnimations() {
if (document->isAnimation() || document->isVideoFile()) {
check.emplace(view);
}
} else if (const auto photo = media->getPhoto()) {
if (photo->hasVideo()) {
check.emplace(view);
}
}
}
}