Update action bar when user is deleted.

GitOrigin-RevId: 1c31884369b944f79b2772e0142ce95a08ebafc1
This commit is contained in:
levlam 2019-10-11 03:11:22 +03:00
parent 9d229b7ad1
commit 62db4169a2
4 changed files with 42 additions and 5 deletions

View File

@ -5770,11 +5770,8 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
if (is_deleted != u->is_deleted) { if (is_deleted != u->is_deleted) {
u->is_deleted = is_deleted; u->is_deleted = is_deleted;
if (u->is_deleted) {
drop_user_full(user_id);
}
LOG(DEBUG) << "User.is_deleted has changed for " << user_id; LOG(DEBUG) << "User.is_deleted has changed for " << user_id;
u->is_is_deleted_changed = true;
u->need_send_update = true; u->need_send_update = true;
} }
@ -5904,7 +5901,7 @@ void ContactsManager::on_save_user_to_database(UserId user_id, bool success) {
<< u->is_deleted << " " << u->is_bot << " " << u->is_changed << " " << u->is_deleted << " " << u->is_bot << " " << u->is_changed << " "
<< u->need_send_update << " " << u->is_status_changed << " " << u->is_name_changed << " " << u->need_send_update << " " << u->is_status_changed << " " << u->is_name_changed << " "
<< u->is_username_changed << " " << u->is_photo_changed << " " << u->is_username_changed << " " << u->is_photo_changed << " "
<< u->is_is_contact_changed; << u->is_is_contact_changed << " " << u->is_is_deleted_changed;
CHECK(load_user_from_database_queries_.count(user_id) == 0); CHECK(load_user_from_database_queries_.count(user_id) == 0);
u->is_being_saved = false; u->is_being_saved = false;
@ -6773,6 +6770,10 @@ void ContactsManager::on_load_user_full_from_database(UserId user_id, string val
} }
update_user_full(user_full, user_id, true); update_user_full(user_full, user_id, true);
if (is_user_deleted(user_id)) {
drop_user_full(user_id);
}
} }
ContactsManager::UserFull *ContactsManager::get_user_full_force(UserId user_id) { ContactsManager::UserFull *ContactsManager::get_user_full_force(UserId user_id) {
@ -6957,6 +6958,15 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo
} }
} }
} }
if (u->is_is_deleted_changed) {
td_->messages_manager_->on_dialog_user_is_deleted_updated(DialogId(user_id), u->is_deleted);
if (u->is_deleted) {
auto user_full = get_user_full(user_id); // must not load user_full from database before sending updateUser
if (user_full != nullptr) {
drop_user_full(user_id);
}
}
}
if (u->is_name_changed) { if (u->is_name_changed) {
td_->messages_manager_->on_dialog_title_updated(DialogId(user_id)); td_->messages_manager_->on_dialog_title_updated(DialogId(user_id));
auto it = secret_chats_with_user_.find(user_id); auto it = secret_chats_with_user_.find(user_id);
@ -7007,6 +7017,7 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo
u->is_username_changed = false; u->is_username_changed = false;
u->is_photo_changed = false; u->is_photo_changed = false;
u->is_is_contact_changed = false; u->is_is_contact_changed = false;
u->is_is_deleted_changed = false;
u->is_default_permissions_changed = false; u->is_default_permissions_changed = false;
if (u->is_deleted) { if (u->is_deleted) {

View File

@ -523,6 +523,7 @@ class ContactsManager : public Actor {
bool is_username_changed = true; bool is_username_changed = true;
bool is_photo_changed = true; bool is_photo_changed = true;
bool is_is_contact_changed = true; bool is_is_contact_changed = true;
bool is_is_deleted_changed = true;
bool is_default_permissions_changed = true; bool is_default_permissions_changed = true;
bool is_changed = true; // have new changes not sent to the database except changes visible to the client bool is_changed = true; // have new changes not sent to the database except changes visible to the client
bool need_send_update = true; // have new changes not sent to the client bool need_send_update = true; // have new changes not sent to the client

View File

@ -22228,6 +22228,30 @@ void MessagesManager::on_dialog_user_is_blocked_updated(DialogId dialog_id, bool
} }
} }
void MessagesManager::on_dialog_user_is_deleted_updated(DialogId dialog_id, bool is_deleted) {
CHECK(dialog_id.get_type() == DialogType::User);
auto d = get_dialog(dialog_id); // called from update_user, must not create the dialog
if (d != nullptr && d->is_update_new_chat_sent) {
if (d->know_action_bar) {
if (is_deleted) {
if (d->can_share_phone_number || d->can_block_user || d->can_add_contact) {
d->can_share_phone_number = false;
d->can_block_user = false;
d->can_add_contact = false;
send_update_chat_action_bar(d);
}
} else {
d->know_action_bar = false;
if (have_input_peer(dialog_id, AccessRights::Read)) {
repair_dialog_action_bar(dialog_id);
}
// there is no need to change action bar
on_dialog_updated(dialog_id, "on_dialog_user_is_deleted_updated");
}
}
}
}
DialogId MessagesManager::resolve_dialog_username(const string &username) const { DialogId MessagesManager::resolve_dialog_username(const string &username) const {
auto cleaned_username = clean_username(username); auto cleaned_username = clean_username(username);
auto it = resolved_usernames_.find(cleaned_username); auto it = resolved_usernames_.find(cleaned_username);

View File

@ -645,6 +645,7 @@ class MessagesManager : public Actor {
void on_dialog_user_is_contact_updated(DialogId dialog_id, bool is_contact); void on_dialog_user_is_contact_updated(DialogId dialog_id, bool is_contact);
void on_dialog_user_is_blocked_updated(DialogId dialog_id, bool is_blocked); void on_dialog_user_is_blocked_updated(DialogId dialog_id, bool is_blocked);
void on_dialog_user_is_deleted_updated(DialogId dialog_id, bool is_deleted);
void on_resolved_username(const string &username, DialogId dialog_id); void on_resolved_username(const string &username, DialogId dialog_id);
void drop_username(const string &username); void drop_username(const string &username);