diff --git a/Telegram/Resources/tl/api.tl b/Telegram/Resources/tl/api.tl index 256f67242..7f1f7f43e 100644 --- a/Telegram/Resources/tl/api.tl +++ b/Telegram/Resources/tl/api.tl @@ -921,6 +921,7 @@ channelAdminLogEventActionChangeHistoryTTL#6e941a38 prev_value:int new_value:int channelAdminLogEventActionParticipantJoinByRequest#afb6144a invite:ExportedChatInvite approved_by:long = ChannelAdminLogEventAction; channelAdminLogEventActionToggleNoForwards#cb2ac766 new_value:Bool = ChannelAdminLogEventAction; channelAdminLogEventActionSendMessage#278f2868 message:Message = ChannelAdminLogEventAction; +channelAdminLogEventActionChangeAvailableReactions#9cf7f76a prev_value:Vector new_value:Vector = ChannelAdminLogEventAction; channelAdminLogEvent#1fad68cd id:long date:int user_id:long action:ChannelAdminLogEventAction = ChannelAdminLogEvent; @@ -1306,13 +1307,13 @@ 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 results:Vector recent_reactons:flags.1?Vector = MessageReactions; +messageReactions#87b6e36 flags:# min:flags.0?true can_see_list:flags.2?true results:Vector recent_reactons: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; -availableReaction#64222f31 reaction:string title:string static_icon:Document select_animation:Document activate_animation:Document effect_animation:Document = AvailableReaction; +availableReaction#21d7c4b flags:# inactive:flags.0?true reaction:string title:string static_icon:Document appear_animation:Document select_animation:Document activate_animation:Document effect_animation:Document = AvailableReaction; messages.availableReactionsNotModified#9f071957 = messages.AvailableReactions; messages.availableReactions#768e3aad hash:int reactions:Vector = messages.AvailableReactions; @@ -1600,6 +1601,7 @@ messages.getMessagesReactions#8bba90e6 peer:InputPeer id: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; 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/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 922ead843..6324e99a1 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -1058,7 +1058,8 @@ void Controller::fillManageSection() { _navigation->parentController()->show(Box( EditAllowedReactionsBox, !_peer->isBroadcast(), - session->data().reactions().list(), + session->data().reactions().list( + Data::Reactions::Type::Active), session->data().reactions().list(_peer), done)); }, diff --git a/Telegram/SourceFiles/data/data_message_reactions.cpp b/Telegram/SourceFiles/data/data_message_reactions.cpp index bcb65cb18..74fd40879 100644 --- a/Telegram/SourceFiles/data/data_message_reactions.cpp +++ b/Telegram/SourceFiles/data/data_message_reactions.cpp @@ -40,8 +40,12 @@ void Reactions::refresh() { request(); } -const std::vector &Reactions::list() const { - return _available; +const std::vector &Reactions::list(Type type) const { + switch (type) { + case Type::Active: return _active; + case Type::All: return _available; + } + Unexpected("Type in Reactions::list."); } std::vector Reactions::list(not_null peer) const { @@ -50,7 +54,7 @@ std::vector Reactions::list(not_null peer) const { } else if (const auto channel = peer->asChannel()) { return filtered(channel->allowedReactions()); } else { - return list(); + return list(Type::Active); } } @@ -95,7 +99,7 @@ void Reactions::resolveImages() { continue; } const auto i = ranges::find(_available, emoji, &Reaction::emoji); - const auto document = (i != end(list())) + const auto document = (i != end(_available)) ? i->staticIcon.get() : nullptr; if (document) { @@ -173,7 +177,7 @@ std::vector Reactions::Filtered( std::vector Reactions::filtered( const std::vector &emoji) const { - return Filtered(list(), emoji); + return Filtered(list(Type::Active), emoji); } std::vector Reactions::ParseAllowed( @@ -188,6 +192,9 @@ std::vector Reactions::ParseAllowed( void Reactions::request() { auto &api = _owner->session().api(); + if (_requestId) { + return; + } _requestId = api.request(MTPmessages_GetAvailableReactions( MTP_int(_hash) )).done([=](const MTPmessages_AvailableReactions &result) { @@ -196,11 +203,16 @@ void Reactions::request() { _hash = data.vhash().v; const auto &list = data.vreactions().v; + _active.clear(); _available.clear(); - _available.reserve(data.vreactions().v.size()); + _active.reserve(list.size()); + _available.reserve(list.size()); for (const auto &reaction : list) { if (const auto parsed = parse(reaction)) { _available.push_back(*parsed); + if (parsed->active) { + _active.push_back(*parsed); + } } } if (_waitingForList) { @@ -228,12 +240,15 @@ std::optional Reactions::parse(const MTPAvailableReaction &entry) { .emoji = emoji, .title = qs(data.vtitle()), .staticIcon = _owner->processDocument(data.vstatic_icon()), + .appearAnimation = _owner->processDocument( + data.vappear_animation()), .selectAnimation = _owner->processDocument( data.vselect_animation()), .activateAnimation = _owner->processDocument( data.vactivate_animation()), .activateEffects = _owner->processDocument( data.veffect_animation()), + .active = !data.is_inactive(), }) : std::nullopt; }); diff --git a/Telegram/SourceFiles/data/data_message_reactions.h b/Telegram/SourceFiles/data/data_message_reactions.h index 45746725a..581536356 100644 --- a/Telegram/SourceFiles/data/data_message_reactions.h +++ b/Telegram/SourceFiles/data/data_message_reactions.h @@ -16,9 +16,11 @@ struct Reaction { QString emoji; QString title; not_null staticIcon; + not_null appearAnimation; not_null selectAnimation; not_null activateAnimation; not_null activateEffects; + bool active = false; }; class Reactions final { @@ -27,7 +29,11 @@ public: void refresh(); - [[nodiscard]] const std::vector &list() const; + enum class Type { + Active, + All, + }; + [[nodiscard]] const std::vector &list(Type type) const; [[nodiscard]] std::vector list(not_null peer) const; [[nodiscard]] static std::vector Filtered( @@ -69,6 +75,7 @@ private: const not_null _owner; + std::vector _active; std::vector _available; rpl::event_stream<> _updated; diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp index e23c1cfb3..c99d59562 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -652,6 +652,7 @@ void GenerateItems( MTPDchannelAdminLogEventActionParticipantJoinByRequest; using LogNoForwards = MTPDchannelAdminLogEventActionToggleNoForwards; using LogActionSendMessage = MTPDchannelAdminLogEventActionSendMessage; + using LogEventActionChangeAvailableReactions = MTPDchannelAdminLogEventActionChangeAvailableReactions; const auto session = &history->session(); const auto id = event.vid().v; @@ -1370,6 +1371,10 @@ void GenerateItems( ExtractSentDate(data.vmessage())); }; + const auto createChangeAvailableReactions = [&](const LogEventActionChangeAvailableReactions &data) { + // #TODO reactions + }; + action.match([&](const LogTitle &data) { createChangeTitle(data); }, [&](const LogAbout &data) { @@ -1440,6 +1445,8 @@ void GenerateItems( createToggleNoForwards(data); }, [&](const LogActionSendMessage &data) { createSendMessage(data); + }, [&](const LogEventActionChangeAvailableReactions &data) { + createChangeAvailableReactions(data); }); }