2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Set / suggest / reset a contact personal photo.

This commit is contained in:
John Preston
2022-12-09 16:34:34 +04:00
parent cb99d611f3
commit 5fe9c93cb6
12 changed files with 190 additions and 72 deletions

View File

@@ -168,7 +168,7 @@ TextWithEntities ForumTopicIconWithTitle(
return (rootId == ForumTopic::kGeneralId)
? TextWithEntities{ u"# "_q + title }
: iconId
? Data::SingleCustomEmoji(iconId).append(title)
? Data::SingleCustomEmoji(iconId).append(' ').append(title)
: TextWithEntities{ title };
}

View File

@@ -423,7 +423,6 @@ private:
mutable Data::CloudImage _userpic;
PhotoId _userpicPhotoId = kUnknownPhotoId;
bool _userpicHasVideo = false;
mutable std::unique_ptr<Ui::EmptyUserpic> _userpicEmpty;
@@ -443,6 +442,7 @@ private:
Settings _settings = PeerSettings(PeerSetting::Unknown);
BlockStatus _blockStatus = BlockStatus::Unknown;
LoadedStatus _loadedStatus = LoadedStatus::Not;
bool _userpicHasVideo = false;
QString _requestChatTitle;
TimeId _requestChatDate = 0;

View File

@@ -54,11 +54,17 @@ void UserData::setIsContact(bool is) {
// see Serialize::readPeer as well
void UserData::setPhoto(const MTPUserProfilePhoto &photo) {
photo.match([&](const MTPDuserProfilePhoto &data) {
if (data.is_personal()) {
addFlags(UserDataFlag::PersonalPhoto);
} else {
removeFlags(UserDataFlag::PersonalPhoto);
}
updateUserpic(
data.vphoto_id().v,
data.vdc_id().v,
data.is_has_video());
}, [&](const MTPDuserProfilePhotoEmpty &) {
removeFlags(UserDataFlag::PersonalPhoto);
clearUserpic();
});
}
@@ -358,6 +364,9 @@ void ApplyUserUpdate(not_null<UserData*> user, const MTPDuserFull &update) {
if (const auto photo = update.vprofile_photo()) {
user->owner().processPhoto(*photo);
}
if (const auto photo = update.vpersonal_photo()) {
user->owner().processPhoto(*photo);
}
user->setSettings(update.vsettings());
user->owner().notifySettings().apply(user, update.vnotify_settings());

View File

@@ -56,6 +56,7 @@ enum class UserDataFlag {
Premium = (1 << 14),
CanReceiveGifts = (1 << 15),
VoiceMessagesForbidden = (1 << 16),
PersonalPhoto = (1 << 17),
};
inline constexpr bool is_flag_type(UserDataFlag) { return true; };
using UserDataFlags = base::flags<UserDataFlag>;