Hide action bar when the user is blocked.

GitOrigin-RevId: 2c317e3612555f496da0b6f2f55f1de60f62cd57
This commit is contained in:
levlam 2019-10-11 00:46:05 +03:00
parent 91bdd50884
commit 24ecd9564e
5 changed files with 35 additions and 1 deletions

View File

@ -628,7 +628,7 @@ chatListArchive = ChatList;
//@last_read_outbox_message_id Identifier of the last read outgoing message
//@unread_mention_count Number of unread messages with a mention/reply in the chat
//@notification_settings Notification settings for this chat
//@action_bar Describes actions which should be possible to do through a chat action bar
//@action_bar Describes actions which should be possible to do through a chat action bar; may be null
//@pinned_message_id Identifier of the pinned message in the chat; 0 if none
//@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
//@draft_message A draft of a message in the chat; may be null

View File

@ -7248,6 +7248,11 @@ void ContactsManager::update_user_full(UserFull *user_full, UserId user_id, bool
td_->messages_manager_->drop_common_dialogs_cache(user_id);
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);
user_full->is_is_blocked_changed = false;
}
if (user_full->is_changed) {
user_full->is_changed = false;
if (user_full->is_inited) {
@ -8028,6 +8033,9 @@ 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);
}
if (user_full == nullptr) {
return;
}
@ -8038,6 +8046,7 @@ void ContactsManager::on_update_user_blocked(UserId user_id, bool is_blocked) {
void ContactsManager::on_update_user_full_is_blocked(UserFull *user_full, UserId user_id, bool is_blocked) {
CHECK(user_full != nullptr);
if (user_full->is_inited && user_full->is_blocked != is_blocked) {
user_full->is_is_blocked_changed = true;
user_full->is_blocked = is_blocked;
user_full->is_changed = true;
}

View File

@ -580,6 +580,7 @@ class ContactsManager : public Actor {
bool can_pin_messages = false;
bool need_phone_number_privacy_exception = false;
bool is_is_blocked_changed = true;
bool is_common_chat_count_changed = true;
bool is_changed = true;

View File

@ -22158,6 +22158,29 @@ void MessagesManager::on_dialog_permissions_updated(DialogId dialog_id) {
}
}
void MessagesManager::on_dialog_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) {
if (d->know_action_bar) {
if (is_blocked) {
if (d->can_report_spam || d->can_share_phone_number || d->can_block_user || d->can_add_contact) {
d->can_report_spam = false;
d->can_share_phone_number = false;
d->can_block_user = false;
d->can_add_contact = false;
// TODO send_update_chat_action_bar(d);
on_dialog_updated(dialog_id, "on_dialog_is_blocked_updated 1");
}
} else {
d->know_action_bar = false;
// TODO repair_dialog_action_bar(d);
on_dialog_updated(dialog_id, "on_dialog_is_blocked_updated 2");
}
}
}
}
DialogId MessagesManager::resolve_dialog_username(const string &username) const {
auto cleaned_username = clean_username(username);
auto it = resolved_usernames_.find(cleaned_username);

View File

@ -642,6 +642,7 @@ 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_resolved_username(const string &username, DialogId dialog_id);
void drop_username(const string &username);