From 839969e2558f0766258b1cf6c26cf87317592790 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 23 Jan 2024 23:11:12 +0300 Subject: [PATCH] Allow tags with label but without count. --- td/generate/scheme/td_api.tl | 2 +- td/telegram/ReactionManager.cpp | 2 +- td/telegram/ReactionManager.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index fc017ddf4..444f4efcd 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1624,7 +1624,7 @@ chatAvailableReactionsAll = ChatAvailableReactions; chatAvailableReactionsSome reactions:vector = ChatAvailableReactions; -//@description Represents a tag used in Saved Messages @tag The tag @label Label of the tag; 0-12 characters @count Number of times the tag was used +//@description Represents a tag used in Saved Messages @tag The tag @label Label of the tag; 0-12 characters @count Number of times the tag was used; may be 0 if the tag has non-empty label savedMessagesTag tag:ReactionType label:string count:int32 = SavedMessagesTag; //@description Contains a list of tags used in Saved Messages @tags List of tags diff --git a/td/telegram/ReactionManager.cpp b/td/telegram/ReactionManager.cpp index eb4027be4..bb76cb9fb 100644 --- a/td/telegram/ReactionManager.cpp +++ b/td/telegram/ReactionManager.cpp @@ -275,7 +275,7 @@ void ReactionManager::SavedReactionTags::update_saved_messages_tags(const vector auto &tag = *it; if (tag.reaction_type_ == old_tag) { tag.count_--; - if (tag.count_ <= 0) { + if (!tag.is_valid()) { tags_.erase(it); } is_changed = true; diff --git a/td/telegram/ReactionManager.h b/td/telegram/ReactionManager.h index fbc9016e1..55d723d75 100644 --- a/td/telegram/ReactionManager.h +++ b/td/telegram/ReactionManager.h @@ -138,7 +138,7 @@ class ReactionManager final : public Actor { SavedReactionTag() = default; bool is_valid() const { - return !reaction_type_.is_empty() && count_ > 0; + return !reaction_type_.is_empty() && count_ >= 0 && (count_ > 0 || !title_.empty()); } explicit SavedReactionTag(telegram_api::object_ptr &&tag);