| 2002 | } |
| 2003 | |
| 2004 | void MessageReactions::remove(const ReactionId &id) { |
| 2005 | Expects(!id.paid()); |
| 2006 | |
| 2007 | const auto history = _item->history(); |
| 2008 | const auto self = history->session().user(); |
| 2009 | const auto i = ranges::find(_list, id, &MessageReaction::id); |
| 2010 | const auto j = _recent.find(id); |
| 2011 | if (i == end(_list)) { |
| 2012 | Assert(j == end(_recent)); |
| 2013 | return; |
| 2014 | } else if (!i->my) { |
| 2015 | Assert(j == end(_recent) |
| 2016 | || !ranges::contains(j->second, self, &RecentReaction::peer)); |
| 2017 | return; |
| 2018 | } |
| 2019 | i->my = false; |
| 2020 | const auto tags = _item->reactionsAreTags(); |
| 2021 | const auto removed = !--i->count; |
| 2022 | if (removed) { |
| 2023 | _list.erase(i); |
| 2024 | } |
| 2025 | if (j != end(_recent)) { |
| 2026 | if (removed) { |
| 2027 | j->second.clear(); |
| 2028 | _recent.erase(j); |
| 2029 | } else { |
| 2030 | j->second.erase( |
| 2031 | ranges::remove(j->second, true, &RecentReaction::my), |
| 2032 | end(j->second)); |
| 2033 | if (j->second.empty()) { |
| 2034 | _recent.erase(j); |
| 2035 | } |
| 2036 | } |
| 2037 | } |
| 2038 | if (tags) { |
| 2039 | const auto sublist = _item->savedSublist(); |
| 2040 | history->owner().reactions().decrementMyTag(id, sublist); |
| 2041 | } |
| 2042 | auto &owner = history->owner(); |
| 2043 | owner.reactions().send(_item, false); |
| 2044 | owner.notifyItemDataChange(_item); |
| 2045 | } |
| 2046 | |
| 2047 | bool MessageReactions::removeFromParticipant( |
| 2048 | not_null<PeerData*> participant, |
no test coverage detected