Fix my_recent_chooser when removing reaction.

This commit is contained in:
levlam 2023-05-01 18:28:06 +03:00
parent e4a15cc0ef
commit f733cb56ce
3 changed files with 9 additions and 3 deletions

View File

@ -741,7 +741,7 @@ bool MessageReactions::add_reaction(const string &reaction, bool is_big, DialogI
return true;
}
bool MessageReactions::remove_reaction(const string &reaction) {
bool MessageReactions::remove_reaction(const string &reaction, DialogId my_dialog_id) {
if (do_remove_reaction(reaction)) {
if (!chosen_reaction_order_.empty()) {
bool is_removed = td::remove(chosen_reaction_order_, reaction);
@ -760,6 +760,10 @@ bool MessageReactions::remove_reaction(const string &reaction) {
}
}
for (auto &message_reaction : reactions_) {
message_reaction.set_my_recent_chooser_dialog_id(my_dialog_id);
}
return true;
}
return false;

View File

@ -175,7 +175,7 @@ struct MessageReactions {
bool add_reaction(const string &reaction, bool is_big, DialogId my_dialog_id, bool have_recent_choosers);
bool remove_reaction(const string &reaction);
bool remove_reaction(const string &reaction, DialogId my_dialog_id);
void sort_reactions(const FlatHashMap<string, size_t> &active_reaction_pos);

View File

@ -23843,7 +23843,9 @@ void MessagesManager::remove_message_reaction(FullMessageId full_message_id, str
return promise.set_error(Status::Error(400, "Invalid reaction specified"));
}
if (m->reactions == nullptr || !m->reactions->remove_reaction(reaction)) {
auto my_dialog_id =
d->default_send_message_as_dialog_id.is_valid() ? d->default_send_message_as_dialog_id : get_my_dialog_id();
if (m->reactions == nullptr || !m->reactions->remove_reaction(reaction, my_dialog_id)) {
return promise.set_value(Unit());
}