Optionally send updates when deleting profile photo.

GitOrigin-RevId: bb916c244857b4f6838d7ae7108415ad4ec3a2a1
This commit is contained in:
levlam 2020-07-20 17:23:32 +03:00
parent 6b00f2fe6b
commit a01ad861bd
2 changed files with 13 additions and 9 deletions

View File

@ -10013,7 +10013,7 @@ void ContactsManager::on_change_profile_photo(tl_object_ptr<telegram_api::photos
void ContactsManager::on_delete_profile_photo(int64 profile_photo_id, Promise<Unit> promise) {
UserId my_user_id = get_my_id();
bool need_reget_user = delete_profile_photo_from_cache(my_user_id, profile_photo_id);
bool need_reget_user = delete_profile_photo_from_cache(my_user_id, profile_photo_id, true);
if (need_reget_user && !G()->close_flag()) {
return reload_user(my_user_id, std::move(promise));
}
@ -10021,7 +10021,7 @@ void ContactsManager::on_delete_profile_photo(int64 profile_photo_id, Promise<Un
promise.set_value(Unit());
}
bool ContactsManager::delete_profile_photo_from_cache(UserId user_id, int64 profile_photo_id) {
bool ContactsManager::delete_profile_photo_from_cache(UserId user_id, int64 profile_photo_id, bool send_updates) {
CHECK(profile_photo_id != 0);
// we have subsequence of user photos in user_photos_
@ -10070,22 +10070,26 @@ bool ContactsManager::delete_profile_photo_from_cache(UserId user_id, int64 prof
user_full->is_changed = true;
get_user_full(user_id, true, Auto());
}
if (send_updates) {
update_user_full(user_full, user_id);
}
}
// update Photo in User
if (is_main_photo_deleted) {
// if main photo is deleted
bool need_reget_user = false;
if (it != user_photos_.end() && it->second.count != -1 && it->second.offset == 0 && !it->second.photos.empty()) {
// found exact new photo
do_update_user_photo(u, user_id, as_profile_photo(it->second.photos[0]), "delete_profile_photo_from_cache");
return false;
} else {
do_update_user_photo(u, user_id, ProfilePhoto(), "delete_profile_photo_from_cache 2");
need_reget_user = it == user_photos_.end() || it->second.count != 0;
}
do_update_user_photo(u, user_id, ProfilePhoto(), "delete_profile_photo_from_cache 2");
return it == user_photos_.end() || it->second.count != 0;
if (send_updates) {
update_user(u, user_id);
}
return need_reget_user;
}
return false;

View File

@ -1138,7 +1138,7 @@ class ContactsManager : public Actor {
void on_update_user_full_need_phone_number_privacy_exception(UserFull *user_full, UserId user_id,
bool need_phone_number_privacy_exception);
bool delete_profile_photo_from_cache(UserId user_id, int64 profile_photo_id);
bool delete_profile_photo_from_cache(UserId user_id, int64 profile_photo_id, bool send_updates);
void drop_user_photos(UserId user_id, bool is_empty, bool drop_user_full_photo, const char *source);
void drop_user_full(UserId user_id);