Fix chosen reaction order in MessageReactions::update_from.

This commit is contained in:
levlam 2023-04-27 17:26:26 +03:00
parent e528c85550
commit b1c627a3be

View File

@ -648,18 +648,23 @@ const MessageReaction *MessageReactions::get_reaction(const string &reaction) co
void MessageReactions::update_from(const MessageReactions &old_reactions) {
if (is_min_ && !old_reactions.is_min_) {
// chosen reaction was known, keep it
// chosen reactions were known, keep them
is_min_ = false;
chosen_reaction_order_ = old_reactions.chosen_reaction_order_;
for (const auto &old_reaction : old_reactions.reactions_) {
if (old_reaction.is_chosen()) {
auto *reaction = get_reaction(old_reaction.get_reaction());
if (reaction != nullptr) {
reaction->update_from(old_reaction);
}
} else {
td::remove(chosen_reaction_order_, old_reaction.get_reaction());
}
}
unread_reactions_ = old_reactions.unread_reactions_;
chosen_reaction_order_ = old_reactions.chosen_reaction_order_;
if (chosen_reaction_order_.size() == 1) {
reset_to_empty(chosen_reaction_order_);
}
}
for (const auto &old_reaction : old_reactions.reactions_) {
if (old_reaction.is_chosen() &&