Add MessageReactions::get_chosen_reactions.

This commit is contained in:
levlam 2022-09-11 14:06:01 +03:00
parent e07ab8e71a
commit 2ee994aed1
3 changed files with 18 additions and 8 deletions

View File

@ -699,6 +699,20 @@ void MessageReactions::fix_chosen_reaction(DialogId my_dialog_id) {
}
}
vector<string> MessageReactions::get_chosen_reactions() const {
if (!chosen_reaction_order_.empty()) {
return chosen_reaction_order_;
}
vector<string> reaction_order;
for (auto &reaction : reactions_) {
if (reaction.is_chosen()) {
reaction_order.push_back(reaction.get_reaction());
}
}
return reaction_order;
}
bool MessageReactions::need_update_message_reactions(const MessageReactions *old_reactions,
const MessageReactions *new_reactions) {
if (old_reactions == nullptr) {

View File

@ -161,6 +161,8 @@ struct MessageReactions {
void fix_chosen_reaction(DialogId my_dialog_id);
vector<string> get_chosen_reactions() const;
static bool need_update_message_reactions(const MessageReactions *old_reactions,
const MessageReactions *new_reactions);

View File

@ -24589,13 +24589,6 @@ void MessagesManager::set_message_reactions(Dialog *d, Message *m, bool is_big,
CHECK(m->reactions != nullptr);
m->reactions->sort_reactions(active_reaction_pos_);
vector<string> reactions;
for (auto &reaction : m->reactions->reactions_) {
if (reaction.is_chosen()) {
reactions.push_back(reaction.get_reaction());
}
}
FullMessageId full_message_id{d->dialog_id, m->message_id};
pending_reactions_[full_message_id].query_count++;
@ -24608,7 +24601,8 @@ void MessagesManager::set_message_reactions(Dialog *d, Message *m, bool is_big,
send_closure(actor_id, &MessagesManager::on_set_message_reactions, full_message_id, std::move(result),
std::move(promise));
});
send_message_reaction(td_, full_message_id, std::move(reactions), is_big, add_to_recent, std::move(query_promise));
send_message_reaction(td_, full_message_id, m->reactions->get_chosen_reactions(), is_big, add_to_recent,
std::move(query_promise));
}
void MessagesManager::on_set_message_reactions(FullMessageId full_message_id, Result<Unit> result,