From cdd7e9239e9ddd9469c331ddb1dc66b5e0567f7c Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Wed, 31 Mar 2021 03:37:34 +0300 Subject: [PATCH] Duplicate invite links to profile --- .../info/profile/info_profile_actions.cpp | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index 2e8e4c0e7..1f27d52cd 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/add_contact_box.h" #include "boxes/peers/edit_contact_box.h" #include "boxes/peers/edit_peer_info_box.h" +#include "boxes/peers/edit_peer_invite_links.h" #include "boxes/peers/edit_participants_box.h" #include "lang/lang_keys.h" #include "info/info_controller.h" @@ -196,6 +197,7 @@ public: private: void addPeerPermissions(not_null peer); void addPeerAdmins(not_null peer); + void addPeerInviteLinks(not_null peer); void addChannelBlockedUsers(not_null channel); void addChannelRecentActions(not_null channel); @@ -927,6 +929,32 @@ void ManageFiller::addPeerAdmins( } } +void ManageFiller::addPeerInviteLinks( + not_null peer) { + if (peer->isUser()) return; + + const auto canHaveInviteLink = [&] { + return peer->isChannel() + ? peer->asChannel()->canHaveInviteLink() + : peer->asChat()->canHaveInviteLink(); + }(); + if (canHaveInviteLink) { + const auto controller = _controller; + auto button = AddActionButton( + _wrap, + tr::lng_manage_peer_invite_links(), + rpl::single(true), + [=] { + Ui::show(Box(ManageInviteLinksBox, peer, peer->session().user(), 0, 0), + Ui::LayerOption::KeepOther); + }); + object_ptr( + button, + st::infoIconInviteLinks, + st::infoSharedMediaButtonIconPosition); + } +} + void ManageFiller::addChannelBlockedUsers( not_null channel) { if (channel->hasAdminRights() || channel->amCreator()) { @@ -970,12 +998,14 @@ void ManageFiller::fillChatActions( not_null chat) { addPeerPermissions(chat); addPeerAdmins(chat); + addPeerInviteLinks(chat); } void ManageFiller::fillChannelActions( not_null channel) { addPeerPermissions(channel); addPeerAdmins(channel); + addPeerInviteLinks(channel); addChannelBlockedUsers(channel); addChannelRecentActions(channel); }