mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to use short info user for fallback photo.
This commit is contained in:
parent
721b2ebe8a
commit
a4d3c694bc
2 changed files with 50 additions and 15 deletions
|
@ -354,7 +354,9 @@ bool ProcessCurrent(
|
||||||
|
|
||||||
[[nodiscard]] PreparedShortInfoUserpic UserpicValue(
|
[[nodiscard]] PreparedShortInfoUserpic UserpicValue(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const style::ShortInfoCover &st) {
|
const style::ShortInfoCover &st,
|
||||||
|
rpl::producer<UserPhotosSlice> slices,
|
||||||
|
Fn<bool(not_null<UserpicState*>)> customProcess) {
|
||||||
const auto moveRequests = std::make_shared<rpl::event_stream<int>>();
|
const auto moveRequests = std::make_shared<rpl::event_stream<int>>();
|
||||||
auto move = [=](int shift) {
|
auto move = [=](int shift) {
|
||||||
moveRequests->fire_copy(shift);
|
moveRequests->fire_copy(shift);
|
||||||
|
@ -367,7 +369,7 @@ bool ProcessCurrent(
|
||||||
state->size = size;
|
state->size = size;
|
||||||
state->roundMask = Images::CornersMask(radius);
|
state->roundMask = Images::CornersMask(radius);
|
||||||
const auto push = [=](bool force = false) {
|
const auto push = [=](bool force = false) {
|
||||||
if (ProcessCurrent(peer, state) || force) {
|
if (customProcess(state) || force) {
|
||||||
consumer.put_next_copy(state->current);
|
consumer.put_next_copy(state->current);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -381,17 +383,12 @@ bool ProcessCurrent(
|
||||||
push();
|
push();
|
||||||
}, lifetime);
|
}, lifetime);
|
||||||
|
|
||||||
if (const auto user = peer->asUser()) {
|
rpl::duplicate(
|
||||||
UserPhotosReversedViewer(
|
slices
|
||||||
&peer->session(),
|
) | rpl::start_with_next([=](UserPhotosSlice &&slice) {
|
||||||
UserPhotosSlice::Key(peerToUser(user->id), PhotoId()),
|
state->userSlice = std::move(slice);
|
||||||
kOverviewLimit,
|
push();
|
||||||
kOverviewLimit
|
}, lifetime);
|
||||||
) | rpl::start_with_next([=](UserPhotosSlice &&slice) {
|
|
||||||
state->userSlice = std::move(slice);
|
|
||||||
push();
|
|
||||||
}, lifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
moveRequests->events(
|
moveRequests->events(
|
||||||
) | rpl::filter([=] {
|
) | rpl::filter([=] {
|
||||||
|
@ -429,7 +426,7 @@ object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||||
: peer->isBroadcast()
|
: peer->isBroadcast()
|
||||||
? PeerShortInfoType::Channel
|
? PeerShortInfoType::Channel
|
||||||
: PeerShortInfoType::Group;
|
: PeerShortInfoType::Group;
|
||||||
auto userpic = UserpicValue(peer, st::shortInfoCover);
|
auto userpic = PrepareShortInfoUserpic(peer, st::shortInfoCover);
|
||||||
auto result = Box<PeerShortInfoBox>(
|
auto result = Box<PeerShortInfoBox>(
|
||||||
type,
|
type,
|
||||||
FieldsValue(peer),
|
FieldsValue(peer),
|
||||||
|
@ -467,5 +464,39 @@ rpl::producer<QString> PrepareShortInfoStatus(not_null<PeerData*> peer) {
|
||||||
PreparedShortInfoUserpic PrepareShortInfoUserpic(
|
PreparedShortInfoUserpic PrepareShortInfoUserpic(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const style::ShortInfoCover &st) {
|
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<UserPhotosSlice>();
|
||||||
|
auto process = [=](not_null<UserpicState*> state) {
|
||||||
|
return ProcessCurrent(peer, state);
|
||||||
|
};
|
||||||
|
return UserpicValue(peer, st, std::move(slices), std::move(process));
|
||||||
|
}
|
||||||
|
|
||||||
|
PreparedShortInfoUserpic PrepareShortInfoFallbackUserpic(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const style::ShortInfoCover &st) {
|
||||||
|
Expects(peer->isUser());
|
||||||
|
|
||||||
|
const auto photoId = SyncUserFallbackPhotoViewer(peer->asUser());
|
||||||
|
auto slices = photoId
|
||||||
|
? rpl::single<UserPhotosSlice>(UserPhotosSlice(
|
||||||
|
Storage::UserPhotosKey(peerToUser(peer->id), *photoId),
|
||||||
|
std::deque<PhotoId>({ *photoId }),
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1))
|
||||||
|
: rpl::never<UserPhotosSlice>();
|
||||||
|
auto process = [=](not_null<UserpicState*> state) {
|
||||||
|
if (photoId) {
|
||||||
|
ProcessFullPhoto(peer, state, peer->owner().photo(*photoId));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
return UserpicValue(peer, st, std::move(slices), std::move(process));
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,3 +45,7 @@ struct PreparedShortInfoUserpic {
|
||||||
[[nodiscard]] PreparedShortInfoUserpic PrepareShortInfoUserpic(
|
[[nodiscard]] PreparedShortInfoUserpic PrepareShortInfoUserpic(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const style::ShortInfoCover &st);
|
const style::ShortInfoCover &st);
|
||||||
|
|
||||||
|
[[nodiscard]] PreparedShortInfoUserpic PrepareShortInfoFallbackUserpic(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const style::ShortInfoCover &st);
|
||||||
|
|
Loading…
Add table
Reference in a new issue