Replace empty action bars with nullptr.

This commit is contained in:
levlam 2021-11-23 09:35:38 +03:00
parent 8fd9d89ec3
commit c7e641aca8
4 changed files with 16 additions and 2 deletions

View File

@ -31,6 +31,11 @@ unique_ptr<DialogActionBar> DialogActionBar::create(bool can_report_spam, bool c
return action_bar;
}
bool DialogActionBar::is_empty() const {
return !can_report_spam && !can_add_contact && !can_block_user && !can_share_phone_number && !can_report_location &&
!can_invite_members;
}
void DialogActionBar::fix(Td *td, DialogId dialog_id, bool is_dialog_blocked, FolderId folder_id) {
auto dialog_type = dialog_id.get_type();
if (distance >= 0 && dialog_type != DialogType::User) {

View File

@ -31,6 +31,8 @@ struct DialogActionBar {
bool can_share_phone_number, bool can_report_location, bool can_unarchive,
int32 distance, bool can_invite_members);
bool is_empty() const;
td_api::object_ptr<td_api::ChatActionBar> get_chat_action_bar_object(DialogType dialog_type,
bool hide_unarchive) const;

View File

@ -8211,6 +8211,10 @@ void MessagesManager::on_get_peer_settings(DialogId dialog_id,
tl_object_ptr<telegram_api::peerSettings> &&peer_settings,
bool ignore_privacy_exception) {
CHECK(peer_settings != nullptr);
if (td_->auth_manager_->is_bot()) {
return;
}
if (dialog_id.get_type() == DialogType::User && !ignore_privacy_exception) {
td_->contacts_manager_->on_update_user_need_phone_number_privacy_exception(dialog_id.get_user_id(),
peer_settings->need_contacts_exception_);
@ -29040,10 +29044,13 @@ void MessagesManager::send_update_secret_chats_with_user_action_bar(const Dialog
});
}
void MessagesManager::send_update_chat_action_bar(const Dialog *d) {
void MessagesManager::send_update_chat_action_bar(Dialog *d) {
if (td_->auth_manager_->is_bot()) {
return;
}
if (d->action_bar != nullptr && d->action_bar->is_empty()) {
d->action_bar = nullptr;
}
CHECK(d != nullptr);
LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_action_bar";

View File

@ -2354,7 +2354,7 @@ class MessagesManager final : public Actor {
void send_update_secret_chats_with_user_action_bar(const Dialog *d) const;
void send_update_chat_action_bar(const Dialog *d);
void send_update_chat_action_bar(Dialog *d);
void send_update_secret_chats_with_user_theme(const Dialog *d) const;