Fix possible assertion violation in non-self reaction.

This commit is contained in:
John Preston 2023-04-23 18:41:14 +04:00
parent 1697e9e791
commit 4eefebc96c
1 changed files with 8 additions and 5 deletions

View File

@ -966,13 +966,16 @@ void MessageReactions::add(const ReactionId &id, bool addToRecent) {
const auto removed = !--one.count;
const auto j = _recent.find(one.id);
if (j != end(_recent)) {
j->second.erase(
ranges::remove(j->second, self, &RecentReaction::peer),
end(j->second));
if (j->second.empty()) {
if (removed) {
j->second.clear();
_recent.erase(j);
} else {
Assert(!removed);
j->second.erase(
ranges::remove(j->second, self, &RecentReaction::peer),
end(j->second));
if (j->second.empty()) {
_recent.erase(j);
}
}
}
return removed;