MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / remove

Method remove

Telegram/SourceFiles/data/data_message_reactions.cpp:2004–2045  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2002}
2003
2004void 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
2047bool MessageReactions::removeFromParticipant(
2048 not_null<PeerData*> participant,

Callers 5

ReactionsMethod · 0.45
sendMethod · 0.45
undoScheduledPaidMethod · 0.45
sendPaidRequestMethod · 0.45

Calls 15

paidMethod · 0.80
reactionsAreTagsMethod · 0.80
savedSublistMethod · 0.80
decrementMyTagMethod · 0.80
reactionsMethod · 0.80
notifyItemDataChangeMethod · 0.80
historyMethod · 0.45
userMethod · 0.45
sessionMethod · 0.45
findMethod · 0.45
eraseMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected