Use combined updateChatAccentColors.

This commit is contained in:
levlam 2023-12-16 11:49:26 +03:00
parent e4e76a7483
commit 16d0c3c61b
5 changed files with 25 additions and 57 deletions

View File

@ -6158,11 +6158,11 @@ updateChatTitle chat_id:int53 title:string = Update;
//@description A chat photo was changed @chat_id Chat identifier @photo The new chat photo; may be null
updateChatPhoto chat_id:int53 photo:chatPhotoInfo = Update;
//@description A chat accent color has changed @chat_id Chat identifier @accent_color_id The new chat accent color identifier
updateChatAccentColor chat_id:int53 accent_color_id:int32 = Update;
//@description A chat's custom emoji for reply background has changed @chat_id Chat identifier @background_custom_emoji_id The new identifier of a custom emoji to be shown on the reply header background; 0 if none
updateChatBackgroundCustomEmoji chat_id:int53 background_custom_emoji_id:int64 = Update;
//@description Chat accent colors has changed
//@chat_id Chat identifier
//@accent_color_id The new chat accent color identifier
//@background_custom_emoji_id The new identifier of a custom emoji to be shown on the reply header background; 0 if none
updateChatAccentColors chat_id:int53 accent_color_id:int32 background_custom_emoji_id:int64 = Update;
//@description Chat permissions were changed @chat_id Chat identifier @permissions The new chat permissions
updateChatPermissions chat_id:int53 permissions:chatPermissions = Update;

View File

@ -12445,27 +12445,13 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo
});
u->is_photo_changed = false;
}
if (u->is_accent_color_id_changed) {
if (u->is_accent_color_changed) {
auto messages_manager = td_->messages_manager_.get();
messages_manager->on_dialog_accent_color_id_updated(DialogId(user_id));
messages_manager->on_dialog_accent_colors_updated(DialogId(user_id));
for_each_secret_chat_with_user(user_id, [messages_manager](SecretChatId secret_chat_id) {
messages_manager->on_dialog_accent_color_id_updated(DialogId(secret_chat_id));
messages_manager->on_dialog_accent_colors_updated(DialogId(secret_chat_id));
});
u->is_accent_color_id_changed = false;
}
if (u->is_background_custom_emoji_id_changed) {
auto messages_manager = td_->messages_manager_.get();
messages_manager->on_dialog_background_custom_emoji_id_updated(DialogId(user_id));
for_each_secret_chat_with_user(user_id, [messages_manager](SecretChatId secret_chat_id) {
messages_manager->on_dialog_background_custom_emoji_id_updated(DialogId(secret_chat_id));
});
u->is_background_custom_emoji_id_changed = false;
}
if (u->is_profile_accent_color_id_changed) {
u->is_profile_accent_color_id_changed = false;
}
if (u->is_profile_background_custom_emoji_id_changed) {
u->is_profile_background_custom_emoji_id_changed = false;
u->is_accent_color_changed = false;
}
if (u->is_phone_number_changed) {
if (!u->phone_number.empty() && !td_->auth_manager_->is_bot()) {
@ -12708,13 +12694,9 @@ void ContactsManager::update_channel(Channel *c, ChannelId channel_id, bool from
}
}
}
if (c->is_accent_color_id_changed) {
td_->messages_manager_->on_dialog_accent_color_id_updated(DialogId(channel_id));
c->is_accent_color_id_changed = false;
}
if (c->is_background_custom_emoji_id_changed) {
td_->messages_manager_->on_dialog_background_custom_emoji_id_updated(DialogId(channel_id));
c->is_background_custom_emoji_id_changed = false;
if (c->is_accent_color_changed) {
td_->messages_manager_->on_dialog_accent_colors_updated(DialogId(channel_id));
c->is_accent_color_changed = false;
}
if (c->is_title_changed) {
td_->messages_manager_->on_dialog_title_updated(DialogId(channel_id));
@ -14091,7 +14073,7 @@ void ContactsManager::on_update_user_accent_color_id(User *u, UserId user_id, Ac
}
if (u->accent_color_id != accent_color_id) {
u->accent_color_id = accent_color_id;
u->is_accent_color_id_changed = true;
u->is_accent_color_changed = true;
u->is_changed = true;
}
}
@ -14100,7 +14082,7 @@ void ContactsManager::on_update_user_background_custom_emoji_id(User *u, UserId
CustomEmojiId background_custom_emoji_id) {
if (u->background_custom_emoji_id != background_custom_emoji_id) {
u->background_custom_emoji_id = background_custom_emoji_id;
u->is_background_custom_emoji_id_changed = true;
u->is_accent_color_changed = true;
u->is_changed = true;
}
}
@ -14111,7 +14093,7 @@ void ContactsManager::on_update_user_profile_accent_color_id(User *u, UserId use
}
if (u->profile_accent_color_id != accent_color_id) {
u->profile_accent_color_id = accent_color_id;
u->is_profile_accent_color_id_changed = true;
u->is_accent_color_changed = true;
u->is_changed = true;
}
}
@ -14120,7 +14102,7 @@ void ContactsManager::on_update_user_profile_background_custom_emoji_id(User *u,
CustomEmojiId background_custom_emoji_id) {
if (u->profile_background_custom_emoji_id != background_custom_emoji_id) {
u->profile_background_custom_emoji_id = background_custom_emoji_id;
u->is_profile_background_custom_emoji_id_changed = true;
u->is_accent_color_changed = true;
u->is_changed = true;
}
}
@ -16824,7 +16806,7 @@ void ContactsManager::on_update_channel_accent_color_id(Channel *c, ChannelId ch
}
if (c->accent_color_id != accent_color_id) {
c->accent_color_id = accent_color_id;
c->is_accent_color_id_changed = true;
c->is_accent_color_changed = true;
c->need_save_to_database = true;
}
}
@ -16833,7 +16815,7 @@ void ContactsManager::on_update_channel_background_custom_emoji_id(Channel *c, C
CustomEmojiId background_custom_emoji_id) {
if (c->background_custom_emoji_id != background_custom_emoji_id) {
c->background_custom_emoji_id = background_custom_emoji_id;
c->is_background_custom_emoji_id_changed = true;
c->is_accent_color_changed = true;
c->need_save_to_database = true;
}
}

View File

@ -824,10 +824,7 @@ class ContactsManager final : public Actor {
bool is_name_changed = true;
bool is_username_changed = true;
bool is_photo_changed = true;
bool is_accent_color_id_changed = true;
bool is_background_custom_emoji_id_changed = true;
bool is_profile_accent_color_id_changed = true;
bool is_profile_background_custom_emoji_id_changed = true;
bool is_accent_color_changed = true;
bool is_phone_number_changed = true;
bool is_emoji_status_changed = true;
bool is_is_contact_changed = true;
@ -1033,8 +1030,7 @@ class ContactsManager final : public Actor {
bool is_title_changed = true;
bool is_username_changed = true;
bool is_photo_changed = true;
bool is_accent_color_id_changed = true;
bool is_background_custom_emoji_id_changed = true;
bool is_accent_color_changed = true;
bool is_default_permissions_changed = true;
bool is_status_changed = true;
bool is_stories_hidden_changed = true;

View File

@ -32714,23 +32714,14 @@ void MessagesManager::on_dialog_photo_updated(DialogId dialog_id) {
}
}
void MessagesManager::on_dialog_accent_color_id_updated(DialogId dialog_id) {
void MessagesManager::on_dialog_accent_colors_updated(DialogId dialog_id) {
auto d = get_dialog(dialog_id); // called from update_user, must not create the dialog
if (d != nullptr && d->is_update_new_chat_sent) {
send_closure(
G()->td(), &Td::send_update,
td_api::make_object<td_api::updateChatAccentColor>(get_chat_id_object(dialog_id, "updateChatAccentColor"),
get_dialog_accent_color_id_object(dialog_id)));
}
}
void MessagesManager::on_dialog_background_custom_emoji_id_updated(DialogId dialog_id) {
auto d = get_dialog(dialog_id); // called from update_user, must not create the dialog
if (d != nullptr && d->is_update_new_chat_sent) {
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateChatBackgroundCustomEmoji>(
get_chat_id_object(dialog_id, "updateChatBackgroundCustomEmoji"),
get_dialog_background_custom_emoji_id(dialog_id).get()));
td_api::make_object<td_api::updateChatAccentColors>(get_chat_id_object(dialog_id, "updateChatAccentColors"),
get_dialog_accent_color_id_object(dialog_id),
get_dialog_background_custom_emoji_id(dialog_id).get()));
}
}

View File

@ -892,8 +892,7 @@ class MessagesManager final : public Actor {
void on_dialog_bots_updated(DialogId dialog_id, vector<UserId> bot_user_ids, bool from_database);
void on_dialog_photo_updated(DialogId dialog_id);
void on_dialog_accent_color_id_updated(DialogId dialog_id);
void on_dialog_background_custom_emoji_id_updated(DialogId dialog_id);
void on_dialog_accent_colors_updated(DialogId dialog_id);
void on_dialog_title_updated(DialogId dialog_id);
void on_dialog_usernames_updated(DialogId dialog_id, const Usernames &old_usernames, const Usernames &new_usernames);
void on_dialog_usernames_received(DialogId dialog_id, const Usernames &usernames, bool from_database);