From 027b23ac5ab6ca7cf6e8599794b772ac4ed51963 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 29 Jan 2024 18:58:30 +0300 Subject: [PATCH] Simplify SavedReactionTags::update_saved_messages_tags. --- td/telegram/ReactionManager.cpp | 19 ++++++------------- td/telegram/ReactionManager.h | 3 +-- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/td/telegram/ReactionManager.cpp b/td/telegram/ReactionManager.cpp index 51023ecfa..ddf29b29c 100644 --- a/td/telegram/ReactionManager.cpp +++ b/td/telegram/ReactionManager.cpp @@ -273,13 +273,12 @@ td_api::object_ptr ReactionManager::SavedReactionTags transform(tags_, [](const SavedReactionTag &tag) { return tag.get_saved_messages_tag_object(); })); } -void ReactionManager::SavedReactionTags::update_saved_messages_tags(const vector &old_tags, - const vector &new_tags, - bool &is_changed, bool &need_reload_title) { +bool ReactionManager::SavedReactionTags::update_saved_messages_tags(const vector &old_tags, + const vector &new_tags) { if (!is_inited_) { - return; + return false; } - is_changed = false; + bool is_changed = false; for (const auto &old_tag : old_tags) { if (!td::contains(new_tags, old_tag)) { CHECK(!old_tag.is_empty()); @@ -310,7 +309,6 @@ void ReactionManager::SavedReactionTags::update_saved_messages_tags(const vector } if (!is_found) { tags_.emplace_back(new_tag, string(), 1); - need_reload_title = true; } } } @@ -318,6 +316,7 @@ void ReactionManager::SavedReactionTags::update_saved_messages_tags(const vector std::sort(tags_.begin(), tags_.end()); hash_ = calc_hash(); } + return is_changed; } bool ReactionManager::SavedReactionTags::set_tag_title(const ReactionType &reaction_type, const string &title) { @@ -965,15 +964,9 @@ void ReactionManager::update_saved_messages_tags(const vector &old if (old_tags == new_tags) { return; } - bool is_changed = false; - bool need_reload_title = false; - tags_.update_saved_messages_tags(old_tags, new_tags, is_changed, need_reload_title); - if (is_changed) { + if (tags_.update_saved_messages_tags(old_tags, new_tags)) { send_update_saved_messages_tags(); } - if (need_reload_title && td_->option_manager_->get_option_boolean("is_premium")) { - on_update_saved_reaction_tags(Auto()); - } } void ReactionManager::set_saved_messages_tag_title(ReactionType reaction_type, string title, Promise &&promise) { diff --git a/td/telegram/ReactionManager.h b/td/telegram/ReactionManager.h index d5aea4ffc..97390515a 100644 --- a/td/telegram/ReactionManager.h +++ b/td/telegram/ReactionManager.h @@ -166,8 +166,7 @@ class ReactionManager final : public Actor { td_api::object_ptr get_saved_messages_tags_object() const; - void update_saved_messages_tags(const vector &old_tags, const vector &new_tags, - bool &is_changed, bool &need_reload_title); + bool update_saved_messages_tags(const vector &old_tags, const vector &new_tags); bool set_tag_title(const ReactionType &reaction_type, const string &title);