Add and use get_chosen_tags.
This commit is contained in:
parent
1b15b2825c
commit
2351a83227
@ -965,4 +965,11 @@ void report_message_reactions(Td *td, MessageFullId message_full_id, DialogId ch
|
|||||||
td->create_handler<ReportReactionQuery>(std::move(promise))->send(dialog_id, message_id, chooser_dialog_id);
|
td->create_handler<ReportReactionQuery>(std::move(promise))->send(dialog_id, message_id, chooser_dialog_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<ReactionType> get_chosen_tags(const unique_ptr<MessageReactions> &message_reactions) {
|
||||||
|
if (message_reactions == nullptr || !message_reactions->are_tags_) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return message_reactions->get_chosen_reaction_types();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -228,4 +228,6 @@ void get_message_added_reactions(Td *td, MessageFullId message_full_id, Reaction
|
|||||||
void report_message_reactions(Td *td, MessageFullId message_full_id, DialogId chooser_dialog_id,
|
void report_message_reactions(Td *td, MessageFullId message_full_id, DialogId chooser_dialog_id,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
vector<ReactionType> get_chosen_tags(const unique_ptr<MessageReactions> &message_reactions);
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -22738,10 +22738,7 @@ void MessagesManager::add_message_reaction(MessageFullId message_full_id, Reacti
|
|||||||
|
|
||||||
LOG(INFO) << "Have message with " << *m->reactions;
|
LOG(INFO) << "Have message with " << *m->reactions;
|
||||||
bool is_tag = can_add_message_tag(dialog_id, m->reactions.get());
|
bool is_tag = can_add_message_tag(dialog_id, m->reactions.get());
|
||||||
vector<ReactionType> old_chosen_tags;
|
auto old_chosen_tags = get_chosen_tags(m->reactions);
|
||||||
if (is_tag) {
|
|
||||||
old_chosen_tags = m->reactions->get_chosen_reaction_types();
|
|
||||||
}
|
|
||||||
if (!m->reactions->add_my_reaction(reaction_type, is_big, get_my_reaction_dialog_id(d), have_recent_choosers,
|
if (!m->reactions->add_my_reaction(reaction_type, is_big, get_my_reaction_dialog_id(d), have_recent_choosers,
|
||||||
is_tag)) {
|
is_tag)) {
|
||||||
return promise.set_value(Unit());
|
return promise.set_value(Unit());
|
||||||
@ -22750,7 +22747,7 @@ void MessagesManager::add_message_reaction(MessageFullId message_full_id, Reacti
|
|||||||
set_message_reactions(d, m, is_big, add_to_recent, std::move(promise));
|
set_message_reactions(d, m, is_big, add_to_recent, std::move(promise));
|
||||||
|
|
||||||
if (is_tag) {
|
if (is_tag) {
|
||||||
td_->reaction_manager_->update_saved_messages_tags(old_chosen_tags, m->reactions->get_chosen_reaction_types());
|
td_->reaction_manager_->update_saved_messages_tags(old_chosen_tags, get_chosen_tags(m->reactions));
|
||||||
} else if (add_to_recent) {
|
} else if (add_to_recent) {
|
||||||
td_->reaction_manager_->add_recent_reaction(reaction_type);
|
td_->reaction_manager_->add_recent_reaction(reaction_type);
|
||||||
}
|
}
|
||||||
@ -22778,19 +22775,15 @@ void MessagesManager::remove_message_reaction(MessageFullId message_full_id, Rea
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOG(INFO) << "Have message with " << *m->reactions;
|
LOG(INFO) << "Have message with " << *m->reactions;
|
||||||
bool is_tag = can_add_message_tag(dialog_id, m->reactions.get());
|
auto old_chosen_tags = get_chosen_tags(m->reactions);
|
||||||
vector<ReactionType> old_chosen_tags;
|
|
||||||
if (is_tag) {
|
|
||||||
old_chosen_tags = m->reactions->get_chosen_reaction_types();
|
|
||||||
}
|
|
||||||
if (!m->reactions->remove_my_reaction(reaction_type, get_my_reaction_dialog_id(d))) {
|
if (!m->reactions->remove_my_reaction(reaction_type, get_my_reaction_dialog_id(d))) {
|
||||||
return promise.set_value(Unit());
|
return promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
set_message_reactions(d, m, false, false, std::move(promise));
|
set_message_reactions(d, m, false, false, std::move(promise));
|
||||||
|
|
||||||
if (is_tag) {
|
if (!old_chosen_tags.empty()) {
|
||||||
td_->reaction_manager_->update_saved_messages_tags(old_chosen_tags, m->reactions->get_chosen_reaction_types());
|
td_->reaction_manager_->update_saved_messages_tags(old_chosen_tags, get_chosen_tags(m->reactions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user