Move DialogActionBar modifiers to DialogActionBar.cpp.
This commit is contained in:
parent
6c1429f74c
commit
8fd9d89ec3
@ -182,6 +182,51 @@ td_api::object_ptr<td_api::ChatActionBar> DialogActionBar::get_chat_action_bar_o
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool DialogActionBar::on_dialog_unarchived() {
|
||||
if (!can_unarchive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
can_unarchive = false;
|
||||
can_report_spam = false;
|
||||
can_block_user = false;
|
||||
// keep can_add_contact
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DialogActionBar::on_user_contact_added() {
|
||||
if (!can_block_user && !can_add_contact) {
|
||||
return false;
|
||||
}
|
||||
|
||||
can_block_user = false;
|
||||
can_add_contact = false;
|
||||
// keep can_unarchive
|
||||
distance = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DialogActionBar::on_user_deleted() {
|
||||
if (!can_share_phone_number && !can_block_user && !can_add_contact && distance < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
can_share_phone_number = false;
|
||||
can_block_user = false;
|
||||
can_add_contact = false;
|
||||
distance = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DialogActionBar::on_outgoing_message() {
|
||||
if (distance < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
distance = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const unique_ptr<DialogActionBar> &lhs, const unique_ptr<DialogActionBar> &rhs) {
|
||||
if (lhs == nullptr) {
|
||||
return rhs == nullptr;
|
||||
|
@ -35,6 +35,14 @@ struct DialogActionBar {
|
||||
bool hide_unarchive) const;
|
||||
|
||||
void fix(Td *td, DialogId dialog_id, bool is_dialog_blocked, FolderId folder_id);
|
||||
|
||||
bool on_dialog_unarchived();
|
||||
|
||||
bool on_user_contact_added();
|
||||
|
||||
bool on_user_deleted();
|
||||
|
||||
bool on_outgoing_message();
|
||||
};
|
||||
|
||||
bool operator==(const unique_ptr<DialogActionBar> &lhs, const unique_ptr<DialogActionBar> &rhs);
|
||||
|
@ -30366,11 +30366,7 @@ void MessagesManager::do_set_dialog_folder_id(Dialog *d, FolderId folder_id) {
|
||||
td_api::make_object<td_api::updateChatActionBar>(d->dialog_id.get(), get_chat_action_bar_object(d)));
|
||||
}
|
||||
}
|
||||
} else if (d->action_bar != nullptr && d->action_bar->can_unarchive && folder_id != FolderId::archive()) {
|
||||
d->action_bar->can_unarchive = false;
|
||||
d->action_bar->can_report_spam = false;
|
||||
d->action_bar->can_block_user = false;
|
||||
// keep d->action_bar->can_add_contact
|
||||
} else if (folder_id != FolderId::archive() && d->action_bar != nullptr && d->action_bar->on_dialog_unarchived()) {
|
||||
send_update_chat_action_bar(d);
|
||||
}
|
||||
|
||||
@ -30645,11 +30641,7 @@ void MessagesManager::on_dialog_user_is_contact_updated(DialogId dialog_id, bool
|
||||
if (d != nullptr && d->is_update_new_chat_sent) {
|
||||
if (d->know_action_bar) {
|
||||
if (is_contact) {
|
||||
if (d->action_bar != nullptr && (d->action_bar->can_block_user || d->action_bar->can_add_contact)) {
|
||||
d->action_bar->can_block_user = false;
|
||||
d->action_bar->can_add_contact = false;
|
||||
// keep d->action_bar->can_unarchive
|
||||
d->action_bar->distance = -1;
|
||||
if (d->action_bar != nullptr && d->action_bar->on_user_contact_added()) {
|
||||
send_update_chat_action_bar(d);
|
||||
}
|
||||
} else {
|
||||
@ -30677,12 +30669,7 @@ void MessagesManager::on_dialog_user_is_deleted_updated(DialogId dialog_id, bool
|
||||
if (d != nullptr && d->is_update_new_chat_sent) {
|
||||
if (d->know_action_bar) {
|
||||
if (is_deleted) {
|
||||
if (d->action_bar != nullptr && (d->action_bar->can_share_phone_number || d->action_bar->can_block_user ||
|
||||
d->action_bar->can_add_contact || d->action_bar->distance >= 0)) {
|
||||
d->action_bar->can_share_phone_number = false;
|
||||
d->action_bar->can_block_user = false;
|
||||
d->action_bar->can_add_contact = false;
|
||||
d->action_bar->distance = -1;
|
||||
if (d->action_bar != nullptr && d->action_bar->on_user_deleted()) {
|
||||
send_update_chat_action_bar(d);
|
||||
}
|
||||
} else {
|
||||
@ -36724,8 +36711,7 @@ void MessagesManager::try_hide_distance(DialogId dialog_id, const Message *m) {
|
||||
d->hide_distance = true;
|
||||
on_dialog_updated(dialog_id, "try_hide_distance");
|
||||
|
||||
if (d->action_bar->distance != -1) {
|
||||
d->action_bar->distance = -1;
|
||||
if (d->action_bar != nullptr && d->action_bar->on_outgoing_message()) {
|
||||
send_update_chat_action_bar(d);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user