From c695545f97126dd041e0a86a5b88b060089312d8 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 25 Dec 2025 18:36:19 +0300 Subject: [PATCH] Returned kick button to list of members but only for inaccessible users. Related commits: d7bf9e285c and 490f6f7e50. --- .../boxes/peers/edit_participants_box.cpp | 10 +++++++++- .../info_profile_members_controllers.cpp | 18 ++++++++++++++++-- .../profile/info_profile_members_controllers.h | 2 ++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index fec694f122..b0004bcc86 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -1902,6 +1902,9 @@ void ParticipantsBoxController::editRestrictedDone( void ParticipantsBoxController::kickParticipant(not_null participant) { const auto user = participant->asUser(); + if (user && user->isInaccessible()) { + return kickParticipantSure(participant); + } const auto text = ((_peer->isChat() || _peer->isMegagroup()) ? tr::lng_profile_sure_kick : tr::lng_profile_sure_kick_channel)( @@ -2128,7 +2131,12 @@ auto ParticipantsBoxController::computeType( : (user && _additional.adminRights(user).has_value()) ? Rights::Admin : Rights::Normal; - result.adminRank = user ? _additional.adminRank(user) : QString(); + result.canRemove = _additional.canRemoveParticipant(participant) + && user + && user->isInaccessible(); + if (!result.canRemove) { + result.adminRank = user ? _additional.adminRank(user) : QString(); + } return result; } diff --git a/Telegram/SourceFiles/info/profile/info_profile_members_controllers.cpp b/Telegram/SourceFiles/info/profile/info_profile_members_controllers.cpp index 619a5206a8..ff5e942166 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_members_controllers.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_members_controllers.cpp @@ -30,7 +30,9 @@ MemberListRow::MemberListRow( void MemberListRow::setType(Type type) { _type = type; - PeerListRowWithLink::setActionLink(!_type.adminRank.isEmpty() + PeerListRowWithLink::setActionLink(_type.canRemove + ? tr::lng_profile_delete_removed(tr::now) + : !_type.adminRank.isEmpty() ? _type.adminRank : (_type.rights == Rights::Creator) ? tr::lng_owner_badge(tr::now) @@ -44,11 +46,19 @@ MemberListRow::Type MemberListRow::type() const { } bool MemberListRow::rightActionDisabled() const { - return true; + return !canRemove(); } QMargins MemberListRow::rightActionMargins() const { const auto skip = st::contactsCheckPosition.x(); + if (canRemove()) { + const auto &st = st::defaultPeerListItem; + return QMargins( + skip, + (st.height - st.nameStyle.font->height) / 2, + st.photoPosition.x() + skip, + 0); + } return QMargins( skip, st::defaultPeerListItem.namePosition.y(), @@ -72,6 +82,10 @@ void MemberListRow::refreshStatus() { } } +bool MemberListRow::canRemove() const { + return _type.canRemove; +} + std::unique_ptr CreateMembersController( not_null navigation, not_null peer) { diff --git a/Telegram/SourceFiles/info/profile/info_profile_members_controllers.h b/Telegram/SourceFiles/info/profile/info_profile_members_controllers.h index c867d731d5..c1c0b2f9cc 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_members_controllers.h +++ b/Telegram/SourceFiles/info/profile/info_profile_members_controllers.h @@ -28,6 +28,7 @@ public: }; struct Type { Rights rights; + bool canRemove = false; QString adminRank; }; @@ -42,6 +43,7 @@ public: not_null user() const; private: + [[nodiscard]] bool canRemove() const; Type _type; };