diff --git a/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp b/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp index 520b46d4c..8f0ef0f8a 100644 --- a/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp @@ -354,7 +354,9 @@ bool ProcessCurrent( [[nodiscard]] PreparedShortInfoUserpic UserpicValue( not_null peer, - const style::ShortInfoCover &st) { + const style::ShortInfoCover &st, + rpl::producer slices, + Fn)> customProcess) { const auto moveRequests = std::make_shared>(); auto move = [=](int shift) { moveRequests->fire_copy(shift); @@ -367,7 +369,7 @@ bool ProcessCurrent( state->size = size; state->roundMask = Images::CornersMask(radius); const auto push = [=](bool force = false) { - if (ProcessCurrent(peer, state) || force) { + if (customProcess(state) || force) { consumer.put_next_copy(state->current); } }; @@ -381,17 +383,12 @@ bool ProcessCurrent( push(); }, lifetime); - if (const auto user = peer->asUser()) { - UserPhotosReversedViewer( - &peer->session(), - UserPhotosSlice::Key(peerToUser(user->id), PhotoId()), - kOverviewLimit, - kOverviewLimit - ) | rpl::start_with_next([=](UserPhotosSlice &&slice) { - state->userSlice = std::move(slice); - push(); - }, lifetime); - } + rpl::duplicate( + slices + ) | rpl::start_with_next([=](UserPhotosSlice &&slice) { + state->userSlice = std::move(slice); + push(); + }, lifetime); moveRequests->events( ) | rpl::filter([=] { @@ -429,7 +426,7 @@ object_ptr PrepareShortInfoBox( : peer->isBroadcast() ? PeerShortInfoType::Channel : PeerShortInfoType::Group; - auto userpic = UserpicValue(peer, st::shortInfoCover); + auto userpic = PrepareShortInfoUserpic(peer, st::shortInfoCover); auto result = Box( type, FieldsValue(peer), @@ -467,5 +464,39 @@ rpl::producer PrepareShortInfoStatus(not_null peer) { PreparedShortInfoUserpic PrepareShortInfoUserpic( not_null peer, const style::ShortInfoCover &st) { - return UserpicValue(peer, st); + auto slices = peer->isUser() + ? UserPhotosReversedViewer( + &peer->session(), + UserPhotosSlice::Key(peerToUser(peer->asUser()->id), PhotoId()), + kOverviewLimit, + kOverviewLimit) + : rpl::never(); + auto process = [=](not_null state) { + return ProcessCurrent(peer, state); + }; + return UserpicValue(peer, st, std::move(slices), std::move(process)); +} + +PreparedShortInfoUserpic PrepareShortInfoFallbackUserpic( + not_null peer, + const style::ShortInfoCover &st) { + Expects(peer->isUser()); + + const auto photoId = SyncUserFallbackPhotoViewer(peer->asUser()); + auto slices = photoId + ? rpl::single(UserPhotosSlice( + Storage::UserPhotosKey(peerToUser(peer->id), *photoId), + std::deque({ *photoId }), + 1, + 1, + 1)) + : rpl::never(); + auto process = [=](not_null state) { + if (photoId) { + ProcessFullPhoto(peer, state, peer->owner().photo(*photoId)); + return true; + } + return false; + }; + return UserpicValue(peer, st, std::move(slices), std::move(process)); } diff --git a/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.h b/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.h index 3572c2138..f50a23bf7 100644 --- a/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.h +++ b/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.h @@ -45,3 +45,7 @@ struct PreparedShortInfoUserpic { [[nodiscard]] PreparedShortInfoUserpic PrepareShortInfoUserpic( not_null peer, const style::ShortInfoCover &st); + +[[nodiscard]] PreparedShortInfoUserpic PrepareShortInfoFallbackUserpic( + not_null peer, + const style::ShortInfoCover &st);