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 removed = !--one.count;
const auto j = _recent.find(one.id); const auto j = _recent.find(one.id);
if (j != end(_recent)) { if (j != end(_recent)) {
j->second.erase( if (removed) {
ranges::remove(j->second, self, &RecentReaction::peer), j->second.clear();
end(j->second));
if (j->second.empty()) {
_recent.erase(j); _recent.erase(j);
} else { } 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; return removed;