Unify *Full.is_changed usage.

GitOrigin-RevId: 222ac98bc06fa5652add8e5d43c7861906209136
This commit is contained in:
levlam 2019-10-21 23:47:58 +03:00
parent bc8f0dcb87
commit de0e0d8173
2 changed files with 37 additions and 23 deletions

View File

@ -7841,23 +7841,31 @@ void ContactsManager::update_user_full(UserFull *user_full, UserId user_id, bool
user_full->is_is_blocked_changed = false;
}
if (user_full->is_changed || user_full->need_send_update) {
user_full->need_send_update |= user_full->is_changed;
user_full->need_save_to_database |= user_full->is_changed;
user_full->is_changed = false;
if (user_full->need_send_update) {
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateUserFullInfo>(get_user_id_object(user_id, "updateUserFullInfo"),
get_user_full_info_object(user_id, user_full)));
if (!from_database && user_full->is_changed) {
save_user_full(user_full, user_id);
}
user_full->is_changed = false;
user_full->need_send_update = false;
}
if (!from_database && user_full->need_save_to_database) {
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateUserFullInfo>(get_user_id_object(user_id, "updateUserFullInfo"),
get_user_full_info_object(user_id, user_full)));
user_full->need_save_to_database = false;
}
}
void ContactsManager::update_chat_full(ChatFull *chat_full, ChatId chat_id, bool from_database) {
CHECK(chat_full != nullptr);
unavailable_chat_fulls_.erase(chat_id); // don't needed anymore
if (chat_full->is_changed || chat_full->need_send_update) {
chat_full->need_send_update |= chat_full->is_changed;
chat_full->need_save_to_database |= chat_full->is_changed;
chat_full->is_changed = false;
if (chat_full->need_send_update) {
vector<UserId> administrator_user_ids;
vector<UserId> bot_user_ids;
for (const auto &participant : chat_full->participants) {
@ -7876,32 +7884,35 @@ void ContactsManager::update_chat_full(ChatFull *chat_full, ChatId chat_id, bool
G()->td(), &Td::send_update,
make_tl_object<td_api::updateBasicGroupFullInfo>(get_basic_group_id_object(chat_id, "update_chat_full"),
get_basic_group_full_info_object(chat_full)));
if (!from_database && chat_full->is_changed) {
save_chat_full(chat_full, chat_id);
}
chat_full->is_changed = false;
chat_full->need_send_update = false;
}
if (!from_database && chat_full->need_save_to_database) {
save_chat_full(chat_full, chat_id);
chat_full->need_save_to_database = false;
}
}
void ContactsManager::update_channel_full(ChannelFull *channel_full, ChannelId channel_id, bool from_database) {
CHECK(channel_full != nullptr);
unavailable_channel_fulls_.erase(channel_id); // don't needed anymore
if (channel_full->participant_count < channel_full->administrator_count) {
channel_full->administrator_count = channel_full->participant_count;
}
channel_full->need_send_update |= channel_full->is_changed;
channel_full->need_save_to_database |= channel_full->is_changed;
if (channel_full->is_changed) {
channel_full->is_changed = false;
if (channel_full->need_send_update) {
if (channel_full->linked_channel_id.is_valid()) {
td_->messages_manager_->force_create_dialog(DialogId(channel_full->linked_channel_id), "update_channel_full");
}
if (channel_full->participant_count < channel_full->administrator_count) {
channel_full->administrator_count = channel_full->participant_count;
}
channel_full->is_changed = false;
send_closure(
G()->td(), &Td::send_update,
make_tl_object<td_api::updateSupergroupFullInfo>(get_supergroup_id_object(channel_id, "update_channel_full"),
get_supergroup_full_info_object(channel_full)));
channel_full->need_send_update = false;
}
if (!from_database && channel_full->need_save_to_database) {
channel_full->need_save_to_database = false;

View File

@ -600,8 +600,9 @@ class ContactsManager : public Actor {
bool is_is_blocked_changed = true;
bool is_common_chat_count_changed = true;
bool is_changed = true; // have new changes that needs to be sent to the client and database
bool need_send_update = true; // have new changes that needs to be sent only to the client
bool is_changed = true; // have new changes that need to be sent to the client and database
bool need_send_update = true; // have new changes that need only to be sent to the client
bool need_save_to_database = true; // have new changes that need onto be saved to the database
double expires_at = 0.0;
@ -664,8 +665,9 @@ class ContactsManager : public Actor {
bool can_set_username = false;
bool is_changed = true; // have new changes that needs to be sent to the client and database
bool need_send_update = true; // have new changes that needs to be sent only to the client
bool is_changed = true; // have new changes that need to be sent to the client and database
bool need_send_update = true; // have new changes that need only to be sent to the client
bool need_save_to_database = true; // have new changes that need onto be saved to the database
template <class StorerT>
void store(StorerT &storer) const;
@ -746,8 +748,9 @@ class ContactsManager : public Actor {
bool can_view_statistics = false;
bool is_all_history_available = true;
bool is_changed = true; // have new changes that needs to be sent to the client and database
bool need_save_to_database = true; // have new changes that needs only to be saved to database
bool is_changed = true; // have new changes that need to be sent to the client and database
bool need_send_update = true; // have new changes that need only to be sent to the client
bool need_save_to_database = true; // have new changes that need onto be saved to the database
double expires_at = 0.0;
bool is_expired() const;