From 05bdef041bbba44e8ce5feaa16c08988bd36ce9c Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 19 Oct 2021 19:07:01 +0400 Subject: [PATCH] Improve PeerShortInfoBox cover updating. --- .../boxes/peers/peer_short_info_box.cpp | 15 +++++++++------ .../boxes/peers/prepare_short_info_box.cpp | 8 ++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp b/Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp index e31ea8c062..85bcffd639 100644 --- a/Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp @@ -345,8 +345,15 @@ void PeerShortInfoBox::applyUserpic(PeerShortInfoUserpic &&value) { refreshBarImages(); update(); } - if (!value.photo.isNull() - && _userpicImage.cacheKey() != value.photo.cacheKey()) { + if (value.photo.isNull()) { + const auto videoChanged = _videoInstance + ? (_videoInstance->shared() != value.videoDocument) + : (value.videoDocument != nullptr); + const auto frame = videoChanged ? currentVideoFrame() : QImage(); + if (!frame.isNull()) { + _userpicImage = frame; + } + } else if (_userpicImage.cacheKey() != value.photo.cacheKey()) { _userpicImage = std::move(value.photo); update(); } @@ -354,10 +361,6 @@ void PeerShortInfoBox::applyUserpic(PeerShortInfoUserpic &&value) { _videoInstance = nullptr; } else if (!_videoInstance || _videoInstance->shared() != value.videoDocument) { - const auto frame = currentVideoFrame(); - if (!frame.isNull()) { - _userpicImage = frame; - } using namespace Media::Streaming; _videoInstance = std::make_unique( std::move(value.videoDocument), diff --git a/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp b/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp index bf713f1152..2c8bca3ddc 100644 --- a/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp @@ -129,6 +129,8 @@ void ProcessFullPhoto( if (!current || state->current.photo.isNull()) { if (const auto blurred = view->thumbnailInline()) { GenerateImage(state, blurred, true); + } else { + state->current.photo = QImage(); } } } @@ -229,8 +231,10 @@ void ValidatePhotoId( PhotoId oldUserpicPhotoId) { if (state->userSlice) { const auto count = state->userSlice->size(); - const auto hasOld = state->userSlice->indexOf(oldUserpicPhotoId); - const auto hasNew = state->userSlice->indexOf(state->userpicPhotoId); + const auto hasOld = state->userSlice->indexOf( + oldUserpicPhotoId).has_value(); + const auto hasNew = state->userSlice->indexOf( + state->userpicPhotoId).has_value(); const auto shift = (hasNew ? 0 : 1); const auto fullCount = count + shift; state->current.count = fullCount;