diff --git a/Telegram/Resources/tl/api.tl b/Telegram/Resources/tl/api.tl index 4f79c76f2..fa80f14d6 100644 --- a/Telegram/Resources/tl/api.tl +++ b/Telegram/Resources/tl/api.tl @@ -190,7 +190,7 @@ messageActionGroupCallScheduled#b3a07661 call:InputGroupCall schedule_date:int = messageActionSetChatTheme#aa786345 emoticon:string = MessageAction; messageActionChatJoinedByRequest#ebbca3cb = MessageAction; -dialog#2c171f72 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog; +dialog#a8edd0f5 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; photoEmpty#2331b22d id:long = Photo; @@ -1307,11 +1307,9 @@ auth.loggedOut#c3a2835f flags:# future_auth_token:flags.0?bytes = auth.LoggedOut reactionCount#6fb250d1 flags:# chosen:flags.0?true reaction:string count:int = ReactionCount; -messageReactions#87b6e36 flags:# min:flags.0?true can_see_list:flags.2?true results:Vector recent_reactons:flags.1?Vector = MessageReactions; +messageReactions#4f2b9479 flags:# min:flags.0?true can_see_list:flags.2?true results:Vector recent_reactions:flags.1?Vector = MessageReactions; -messageUserReaction#932844fa user_id:long reaction:string = MessageUserReaction; - -messages.messageReactionsList#a366923c flags:# count:int reactions:Vector users:Vector next_offset:flags.0?string = messages.MessageReactionsList; +messages.messageReactionsList#31bd492d flags:# count:int reactions:Vector chats:Vector users:Vector next_offset:flags.0?string = messages.MessageReactionsList; availableReaction#c077ec01 flags:# inactive:flags.0?true reaction:string title:string static_icon:Document appear_animation:Document select_animation:Document activate_animation:Document effect_animation:Document around_animation:flags.1?Document center_icon:flags.1?Document = AvailableReaction; @@ -1321,6 +1319,8 @@ messages.availableReactions#768e3aad hash:int reactions:Vector = Updates; messages.getMessageReactionsList#e0ee6b77 flags:# peer:InputPeer id:int reaction:flags.0?string offset:flags.1?string limit:int = messages.MessageReactionsList; messages.setChatAvailableReactions#14050ea6 peer:InputPeer available_reactions:Vector = Updates; messages.getAvailableReactions#18dea0ac hash:int = messages.AvailableReactions; messages.setDefaultReaction#d960c4d4 reaction:string = Bool; messages.translateText#24ce6dee flags:# peer:flags.0?InputPeer msg_id:flags.0?int text:flags.1?string from_lang:flags.2?string to_lang:string = messages.TranslatedText; +messages.getUnreadReactions#e85bae1a peer:InputPeer offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages; +messages.readReactions#82e251d7 peer:InputPeer = messages.AffectedHistory; updates.getState#edd4882a = updates.State; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; diff --git a/Telegram/SourceFiles/api/api_who_reacted.cpp b/Telegram/SourceFiles/api/api_who_reacted.cpp index 9e7e46e29..4aa679ed4 100644 --- a/Telegram/SourceFiles/api/api_who_reacted.cpp +++ b/Telegram/SourceFiles/api/api_who_reacted.cpp @@ -289,6 +289,7 @@ struct State { result.match([&]( const MTPDmessages_messageReactionsList &data) { session->data().processUsers(data.vusers()); + session->data().processChats(data.vchats()); auto parsed = PeersWithReactions{ .fullReactionsCount = data.vcount().v, @@ -297,7 +298,7 @@ struct State { for (const auto &vote : data.vreactions().v) { vote.match([&](const auto &data) { parsed.list.push_back(PeerWithReaction{ - .peer = peerFromUser(data.vuser_id()), + .peer = peerFromMTP(data.vpeer_id()), .reaction = qs(data.vreaction()), }); }); diff --git a/Telegram/SourceFiles/data/data_message_reactions.cpp b/Telegram/SourceFiles/data/data_message_reactions.cpp index 1ffc5494e..e00a9a85f 100644 --- a/Telegram/SourceFiles/data/data_message_reactions.cpp +++ b/Telegram/SourceFiles/data/data_message_reactions.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "main/main_account.h" #include "main/main_app_config.h" +#include "data/data_user.h" #include "data/data_session.h" #include "data/data_changes.h" #include "data/data_document.h" @@ -516,7 +517,7 @@ void MessageReactions::remove() { void MessageReactions::set( const QVector &list, - const QVector &recent, + const QVector &recent, bool ignoreChosen) { auto &owner = _item->history()->owner(); if (owner.reactions().sending(_item)) { @@ -558,12 +559,13 @@ void MessageReactions::set( } auto parsed = base::flat_map< QString, - std::vector>>(); + std::vector>>(); for (const auto &reaction : recent) { - reaction.match([&](const MTPDmessageUserReaction &data) { + reaction.match([&](const MTPDmessagePeerReaction &data) { const auto emoji = qs(data.vreaction()); if (_list.contains(emoji)) { - parsed[emoji].push_back(owner.user(data.vuser_id())); + parsed[emoji].push_back( + owner.peer(peerFromMTP(data.vpeer_id()))); } }); } @@ -582,7 +584,7 @@ const base::flat_map &MessageReactions::list() const { } auto MessageReactions::recent() const --> const base::flat_map>> & { +-> const base::flat_map>> & { return _recent; } diff --git a/Telegram/SourceFiles/data/data_message_reactions.h b/Telegram/SourceFiles/data/data_message_reactions.h index 79626eddc..a83fe1018 100644 --- a/Telegram/SourceFiles/data/data_message_reactions.h +++ b/Telegram/SourceFiles/data/data_message_reactions.h @@ -133,11 +133,11 @@ public: void remove(); void set( const QVector &list, - const QVector &recent, + const QVector &recent, bool ignoreChosen); [[nodiscard]] const base::flat_map &list() const; [[nodiscard]] auto recent() const - -> const base::flat_map>> &; + -> const base::flat_map>> &; [[nodiscard]] QString chosen() const; [[nodiscard]] bool empty() const; @@ -146,7 +146,7 @@ private: QString _chosen; base::flat_map _list; - base::flat_map>> _recent; + base::flat_map>> _recent; }; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index e04fa612f..48e51581d 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -862,7 +862,7 @@ void HistoryItem::setReactions(const MTPMessageReactions *reactions) { } _reactions->set( data.vresults().v, - data.vrecent_reactons().value_or_empty(), + data.vrecent_reactions().value_or_empty(), data.is_min()); }); } @@ -877,10 +877,10 @@ const base::flat_map &HistoryItem::reactions() const { } auto HistoryItem::recentReactions() const --> const base::flat_map>> & { +-> const base::flat_map>> & { static const auto kEmpty = base::flat_map< QString, - std::vector>>(); + std::vector>>(); return _reactions ? _reactions->recent() : kEmpty; } diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 28ea5bc30..b446071b5 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -360,7 +360,7 @@ public: void updateReactionsUnknown(); [[nodiscard]] const base::flat_map &reactions() const; [[nodiscard]] auto recentReactions() const - -> const base::flat_map>> &; + -> const base::flat_map>> &; [[nodiscard]] bool canViewReactions() const; [[nodiscard]] QString chosenReaction() const; [[nodiscard]] QString lookupHisReaction() const; diff --git a/Telegram/SourceFiles/history/view/history_view_reactions.cpp b/Telegram/SourceFiles/history/view/history_view_reactions.cpp index 81277737d..0ad430e9f 100644 --- a/Telegram/SourceFiles/history/view/history_view_reactions.cpp +++ b/Telegram/SourceFiles/history/view/history_view_reactions.cpp @@ -15,7 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_group_call_bar.h" #include "core/click_handler_types.h" #include "data/data_message_reactions.h" -#include "data/data_user.h" +#include "data/data_peer.h" #include "lang/lang_tag.h" #include "ui/chat/chat_style.h" #include "styles/style_chat.h" @@ -125,18 +125,18 @@ void InlineList::setButtonCount(Button &button, int count) { void InlineList::setButtonUserpics( Button &button, - const std::vector> &users) { + const std::vector> &peers) { if (!button.userpics) { button.userpics = std::make_unique(); } - const auto count = button.count = int(users.size()); + const auto count = button.count = int(peers.size()); auto &list = button.userpics->list; const auto regenerate = [&] { if (list.size() != count) { return true; } for (auto i = 0; i != count; ++i) { - if (users[i] != list[i].peer) { + if (peers[i] != list[i].peer) { return true; } } @@ -150,10 +150,10 @@ void InlineList::setButtonUserpics( for (auto i = 0; i != count; ++i) { if (i == list.size()) { list.push_back(UserpicInRow{ - users[i] + peers[i] }); - } else if (list[i].peer != users[i]) { - list[i].peer = users[i]; + } else if (list[i].peer != peers[i]) { + list[i].peer = peers[i]; } } while (list.size() > count) { diff --git a/Telegram/SourceFiles/history/view/history_view_reactions.h b/Telegram/SourceFiles/history/view/history_view_reactions.h index a449ebb57..2629d8fe5 100644 --- a/Telegram/SourceFiles/history/view/history_view_reactions.h +++ b/Telegram/SourceFiles/history/view/history_view_reactions.h @@ -40,7 +40,7 @@ struct InlineListData { using Flags = base::flags; base::flat_map reactions; - base::flat_map>> recent; + base::flat_map>> recent; QString chosenReaction; Flags flags = {}; }; @@ -101,7 +101,7 @@ private: void setButtonCount(Button &button, int count); void setButtonUserpics( Button &button, - const std::vector> &users); + const std::vector> &peers); [[nodiscard]] Button prepareButtonWithEmoji(const QString &emoji); void resolveUserpicsImage(const Button &button) const; diff --git a/Telegram/SourceFiles/history/view/reactions/message_reactions_list.cpp b/Telegram/SourceFiles/history/view/reactions/message_reactions_list.cpp index 16dac6daf..a5f6e6799 100644 --- a/Telegram/SourceFiles/history/view/reactions/message_reactions_list.cpp +++ b/Telegram/SourceFiles/history/view/reactions/message_reactions_list.cpp @@ -17,7 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/controls/who_reacted_context_action.h" #include "main/main_session.h" #include "data/data_session.h" -#include "data/data_user.h" +#include "data/data_peer.h" #include "lang/lang_keys.h" namespace HistoryView { @@ -61,13 +61,13 @@ public: void loadMoreRows() override; private: - using AllEntry = std::pair, QString>; + using AllEntry = std::pair, QString>; void fillWhoRead(); void loadMore(const QString &reaction); - bool appendRow(not_null user, QString reaction); + bool appendRow(not_null peer, QString reaction); std::unique_ptr createRow( - not_null user, + not_null peer, QString reaction) const; void showReaction(const QString &reaction); @@ -77,12 +77,12 @@ private: QString _shownReaction; std::shared_ptr _whoReadIds; - std::vector> _whoRead; + std::vector> _whoRead; std::vector _all; QString _allOffset; - std::vector> _filtered; + std::vector> _filtered; QString _filteredOffset; mtpRequestId _loadRequestId = 0; @@ -179,8 +179,8 @@ void Controller::showReaction(const QString &reaction) { fillWhoRead(); } else if (_shownReaction.isEmpty()) { _filtered.clear(); - for (const auto &[user, reaction] : _all) { - appendRow(user, reaction); + for (const auto &[peer, reaction] : _all) { + appendRow(peer, reaction); } } else { _filtered = _all | ranges::view::filter([&](const AllEntry &entry) { @@ -188,8 +188,8 @@ void Controller::showReaction(const QString &reaction) { }) | ranges::view::transform( &AllEntry::first ) | ranges::to_vector; - for (const auto user : _filtered) { - appendRow(user, _shownReaction); + for (const auto peer : _filtered) { + appendRow(peer, _shownReaction); } _filteredOffset = QString(); } @@ -204,13 +204,13 @@ void Controller::fillWhoRead() { if (_whoReadIds && !_whoReadIds->list.empty() && _whoRead.empty()) { auto &owner = _window->session().data(); for (const auto &peerId : _whoReadIds->list) { - if (const auto user = owner.userLoaded(peerToUser(peerId))) { - _whoRead.push_back(user); + if (const auto peer = owner.peerLoaded(peerId)) { + _whoRead.push_back(peer); } } } - for (const auto &user : _whoRead) { - appendRow(user, QString()); + for (const auto &peer : _whoRead) { + appendRow(peer, QString()); } } @@ -255,18 +255,19 @@ void Controller::loadMore(const QString &reaction) { result.match([&](const MTPDmessages_messageReactionsList &data) { const auto sessionData = &session().data(); sessionData->processUsers(data.vusers()); + sessionData->processChats(data.vchats()); (filtered ? _filteredOffset : _allOffset) = data.vnext_offset().value_or_empty(); for (const auto &reaction : data.vreactions().v) { - reaction.match([&](const MTPDmessageUserReaction &data) { - const auto user = sessionData->userLoaded( - data.vuser_id().v); + reaction.match([&](const MTPDmessagePeerReaction &data) { + const auto peer = sessionData->peerLoaded( + peerFromMTP(data.vpeer_id())); const auto reaction = qs(data.vreaction()); - if (user && (!shown || appendRow(user, reaction))) { + if (peer && (!shown || appendRow(peer, reaction))) { if (filtered) { - _filtered.emplace_back(user); + _filtered.emplace_back(peer); } else { - _all.emplace_back(user, reaction); + _all.emplace_back(peer, reaction); } } }); @@ -287,18 +288,18 @@ void Controller::rowClicked(not_null row) { }); } -bool Controller::appendRow(not_null user, QString reaction) { - if (delegate()->peerListFindRow(user->id.value)) { +bool Controller::appendRow(not_null peer, QString reaction) { + if (delegate()->peerListFindRow(peer->id.value)) { return false; } - delegate()->peerListAppendRow(createRow(user, reaction)); + delegate()->peerListAppendRow(createRow(peer, reaction)); return true; } std::unique_ptr Controller::createRow( - not_null user, + not_null peer, QString reaction) const { - return std::make_unique(user, reaction); + return std::make_unique(peer, reaction); } } // namespace