Add MessageReaction::update_from.

This commit is contained in:
levlam 2023-04-27 16:37:15 +03:00
parent 2d0fa11624
commit 89cd51b461
2 changed files with 13 additions and 1 deletions

View File

@ -422,6 +422,16 @@ bool MessageReaction::remove_recent_chooser_dialog_id() {
return false;
}
void MessageReaction::update_from(const MessageReaction &old_reaction) {
CHECK(old_reaction.is_chosen());
is_chosen_ = true;
auto my_dialog_id = old_reaction.get_my_recent_chooser_dialog_id();
if (my_dialog_id.is_valid() && td::contains(recent_chooser_dialog_ids_, my_dialog_id)) {
my_recent_chooser_dialog_id_ = my_dialog_id;
}
}
void MessageReaction::update_recent_chooser_dialog_ids(const MessageReaction &old_reaction) {
if (recent_chooser_dialog_ids_.size() != MAX_RECENT_CHOOSERS) {
return;
@ -643,7 +653,7 @@ void MessageReactions::update_from(const MessageReactions &old_reactions) {
if (old_reaction.is_chosen()) {
auto *reaction = get_reaction(old_reaction.get_reaction());
if (reaction != nullptr) {
reaction->set_is_chosen(true, DialogId(), false);
reaction->update_from(old_reaction);
}
}
}

View File

@ -71,6 +71,8 @@ class MessageReaction {
bool remove_recent_chooser_dialog_id();
void update_from(const MessageReaction &old_reaction);
void update_recent_chooser_dialog_ids(const MessageReaction &old_reaction);
int32 get_choose_count() const {