2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +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

@@ -398,7 +398,7 @@ void MediaView::updateActions() {
return true;
} else if (!_msgid && _photo && App::self() && _user == App::self()) {
return _userPhotosData && _fullIndex && _fullCount;
} else if (_photo && _photo->peer && _photo->peer->photoId == _photo->id) {
} else if (_photo && _photo->peer && _photo->peer->userpicPhotoId() == _photo->id) {
if (auto chat = _photo->peer->asChat()) {
return chat->canEdit();
} else if (auto channel = _photo->peer->asChannel()) {
@@ -948,7 +948,7 @@ void MediaView::onDelete() {
auto deletingPeerPhoto = [this]() {
if (!_msgid) return true;
if (_photo && _history) {
if (_history->peer->photoId == _photo->id) {
if (_history->peer->userpicPhotoId() == _photo->id) {
return _firstOpenedPeerPhoto;
}
}
@@ -1010,12 +1010,12 @@ base::optional<MediaView::SharedMediaType> MediaView::sharedMediaType() const {
}
base::optional<MediaView::SharedMediaKey> MediaView::sharedMediaKey() const {
if (!_msgid && _peer && !_user && _photo && _peer->photoId == _photo->id) {
if (!_msgid && _peer && !_user && _photo && _peer->userpicPhotoId() == _photo->id) {
return SharedMediaKey {
_history->peer->id,
_migrated ? _migrated->peer->id : 0,
SharedMediaType::ChatPhoto,
_peer->photoId
_peer->userpicPhotoId()
};
}
if (!IsServerMsgId(_msgid.msg)) {