2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Refactor userpic storage and access in PeerData.

This commit is contained in:
John Preston
2017-12-05 10:41:43 +04:00
parent 62568daffe
commit 68009b6fba
16 changed files with 211 additions and 217 deletions

View File

@@ -436,20 +436,26 @@ void Panel::processUserPhoto() {
if (!_user->userpicLoaded()) {
_user->loadUserpic(true);
}
auto photo = (_user->photoId && _user->photoId != UnknownPeerPhotoId) ? App::photo(_user->photoId) : nullptr;
const auto photo = _user->userpicPhotoId()
? App::photo(_user->userpicPhotoId())
: nullptr;
if (isGoodUserPhoto(photo)) {
photo->full->load(true);
} else {
if ((_user->photoId == UnknownPeerPhotoId) || (_user->photoId && (!photo || !photo->date))) {
Auth().api().requestFullPeer(_user);
}
} else if (_user->userpicPhotoUnknown() || (photo && !photo->date)) {
Auth().api().requestFullPeer(_user);
}
refreshUserPhoto();
}
void Panel::refreshUserPhoto() {
auto photo = (_user->photoId && _user->photoId != UnknownPeerPhotoId) ? App::photo(_user->photoId) : nullptr;
if (isGoodUserPhoto(photo) && photo->full->loaded() && (photo->id != _userPhotoId || !_userPhotoFull)) {
const auto photo = _user->userpicPhotoId()
? App::photo(_user->userpicPhotoId())
: nullptr;
const auto isNewPhoto = [&](not_null<PhotoData*> photo) {
return photo->full->loaded()
&& (photo->id != _userPhotoId || !_userPhotoFull);
};
if (isGoodUserPhoto(photo) && isNewPhoto(photo)) {
_userPhotoId = photo->id;
_userPhotoFull = true;
createUserpicCache(photo->full);