From 16d0c3c61b28637741d2b5e88617f01aad6ba29c Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 16 Dec 2023 11:49:26 +0300 Subject: [PATCH] Use combined updateChatAccentColors. --- td/generate/scheme/td_api.tl | 10 ++++---- td/telegram/ContactsManager.cpp | 44 ++++++++++----------------------- td/telegram/ContactsManager.h | 8 ++---- td/telegram/MessagesManager.cpp | 17 +++---------- td/telegram/MessagesManager.h | 3 +-- 5 files changed, 25 insertions(+), 57 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 0732cff2c..041683c91 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -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; diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index ba981a1e8..e674c5fa8 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -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; } } diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index f9c4d22e2..dd2918bbd 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -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; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 5958c8203..6db1b8a08 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -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(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( - get_chat_id_object(dialog_id, "updateChatBackgroundCustomEmoji"), - get_dialog_background_custom_emoji_id(dialog_id).get())); + td_api::make_object(get_chat_id_object(dialog_id, "updateChatAccentColors"), + get_dialog_accent_color_id_object(dialog_id), + get_dialog_background_custom_emoji_id(dialog_id).get())); } } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 6a31524ba..62dc95bc9 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -892,8 +892,7 @@ class MessagesManager final : public Actor { void on_dialog_bots_updated(DialogId dialog_id, vector 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);