Update action bar when user is added to contacts.

GitOrigin-RevId: 52883ca7e29a3f1b9fe86a7cb210daba5c8cef46
This commit is contained in:
levlam 2019-10-11 02:59:40 +03:00
parent a9dbaa6b78
commit 9d229b7ad1
3 changed files with 31 additions and 5 deletions

View File

@ -6948,6 +6948,7 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo
update_contacts_hints(u, user_id, from_database);
}
if (u->is_is_contact_changed) {
td_->messages_manager_->on_dialog_user_is_contact_updated(DialogId(user_id), u->is_contact);
if (u->is_contact) {
auto user_full = get_user_full(user_id);
if (user_full != nullptr && user_full->need_phone_number_privacy_exception) {
@ -7249,7 +7250,7 @@ void ContactsManager::update_user_full(UserFull *user_full, UserId user_id, bool
user_full->is_common_chat_count_changed = false;
}
if (user_full->is_is_blocked_changed) {
td_->messages_manager_->on_dialog_is_blocked_updated(DialogId(user_id), user_full->is_blocked);
td_->messages_manager_->on_dialog_user_is_blocked_updated(DialogId(user_id), user_full->is_blocked);
user_full->is_is_blocked_changed = false;
}
@ -8034,7 +8035,7 @@ void ContactsManager::on_update_user_blocked(UserId user_id, bool is_blocked) {
UserFull *user_full = get_user_full_force(user_id);
if (user_full == nullptr || !user_full->is_inited) {
td_->messages_manager_->on_dialog_is_blocked_updated(DialogId(user_id), is_blocked);
td_->messages_manager_->on_dialog_user_is_blocked_updated(DialogId(user_id), is_blocked);
}
if (user_full == nullptr) {
return;

View File

@ -22180,7 +22180,30 @@ void MessagesManager::on_dialog_permissions_updated(DialogId dialog_id) {
}
}
void MessagesManager::on_dialog_is_blocked_updated(DialogId dialog_id, bool is_blocked) {
void MessagesManager::on_dialog_user_is_contact_updated(DialogId dialog_id, bool is_contact) {
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_contact) {
if (d->can_block_user || d->can_add_contact) {
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_contact_updated");
}
}
}
}
void MessagesManager::on_dialog_user_is_blocked_updated(DialogId dialog_id, bool is_blocked) {
CHECK(dialog_id.get_type() == DialogType::User);
auto d = get_dialog(dialog_id); // called from update_user_full, must not create the dialog
if (d != nullptr && d->is_update_new_chat_sent) {
@ -22199,7 +22222,7 @@ void MessagesManager::on_dialog_is_blocked_updated(DialogId dialog_id, bool is_b
repair_dialog_action_bar(dialog_id);
}
// there is no need to change action bar
on_dialog_updated(dialog_id, "on_dialog_is_blocked_updated");
on_dialog_updated(dialog_id, "on_dialog_user_is_blocked_updated");
}
}
}

View File

@ -642,7 +642,9 @@ class MessagesManager : public Actor {
void on_dialog_title_updated(DialogId dialog_id);
void on_dialog_username_updated(DialogId dialog_id, const string &old_username, const string &new_username);
void on_dialog_permissions_updated(DialogId dialog_id);
void on_dialog_is_blocked_updated(DialogId dialog_id, bool is_blocked);
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_resolved_username(const string &username, DialogId dialog_id);
void drop_username(const string &username);