diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 057d288e00..90967b9fdf 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -145,8 +145,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_sure_add_admin_invite_channel" = "This user is not a subscriber of this channel. Add them to the channel and promote them to admin?"; "lng_sure_add_admin_unremove" = "This user is currently restricted or removed. Are you sure you want to promote them?"; "lng_sure_ban_admin" = "This user is an admin. Are you sure you want to go ahead and restrict them?"; -"lng_sure_remove_user_group" = "Remove {user} from the group?"; -"lng_sure_remove_user_channel" = "Remove {user} from the channel?"; "lng_sure_enable_socks" = "Are you sure you want to enable this proxy?\n\nServer: {server}\nPort: {port}\n\nYou can change your proxy server later in the Settings (Connection Type)."; "lng_sure_enable" = "Enable"; diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp index 2883bd832c..6d9ca16600 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp @@ -710,27 +710,30 @@ void AddSpecialBoxController::kickUser( // Finally kick him. if (!sure) { const auto text = ((_peer->isChat() || _peer->isMegagroup()) - ? lng_sure_remove_user_group - : lng_sure_remove_user_channel)(lt_user, App::peerName(user)); + ? lng_profile_sure_kick + : lng_profile_sure_kick_channel)(lt_user, App::peerName(user)); _editBox = Ui::show( Box(text, kickUserSure), LayerOption::KeepOther); return; } - _editBox = nullptr; const auto restrictedRights = _additional.restrictedRights(user); const auto currentRights = restrictedRights ? *restrictedRights : MTPChatBannedRights(MTP_chatBannedRights( MTP_flags(0), MTP_int(0))); - auto &session = _peer->session(); - if (const auto chat = _peer->asChat()) { - session.api().kickParticipant(chat, user); - } else if (const auto channel = _peer->asChannel()) { - session.api().kickParticipant(channel, user, currentRights); - } + + const auto done = crl::guard(this, [=]( + const MTPChatBannedRights &newRights) { + editRestrictedDone(user, newRights); + }); + const auto fail = crl::guard(this, [=] { + _editBox = nullptr; + }); + const auto callback = SaveRestrictedCallback(_peer, user, done, fail); + callback(currentRights, ChannelData::KickedRestrictedRights()); } bool AddSpecialBoxController::appendRow(not_null user) { diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.h b/Telegram/SourceFiles/boxes/peers/add_participants_box.h index 9da139a677..2fed9092e4 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.h +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.h @@ -95,10 +95,6 @@ private: not_null user, const MTPChatBannedRights &rights); void kickUser(not_null user, bool sure = false); - void restrictUserSure( - not_null user, - const MTPChatBannedRights &oldRights, - const MTPChatBannedRights &newRights); bool appendRow(not_null user); bool prependRow(not_null user); std::unique_ptr createRow(not_null user) const; diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 6a68e10af8..d34e439c07 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -179,6 +179,26 @@ void SaveChannelRestriction( }).send(); } +void SaveChatParticipantKick( + not_null chat, + not_null user, + Fn onDone, + Fn onFail) { + chat->session().api().request(MTPmessages_DeleteChatUser( + chat->inputChat, + user->inputUser + )).done([=](const MTPUpdates &result) { + chat->session().api().applyUpdates(result); + if (onDone) { + onDone(); + } + }).fail([=](const RPCError &error) { + if (onFail) { + onFail(); + } + }).send(); +} + } // namespace Fnsession().api().migrateChat(chat, saveForChannel); @@ -1333,8 +1355,6 @@ void ParticipantsBoxController::rowActionClicked( kickMember(user); } else if (_role == Role::Admins) { removeAdmin(user); - } else if (_role == Role::Restricted) { - showRestricted(user); } else { removeKicked(row, user); } @@ -1628,6 +1648,10 @@ void ParticipantsBoxController::removeKicked( not_null row, not_null user) { delegate()->peerListRemoveRow(row); + if (_role != Role::Kicked + && !delegate()->peerListFullRowsCount()) { + setDescriptionText(lang(lng_blocked_list_not_found)); + } delegate()->peerListRefreshRows(); removeKicked(user); } @@ -1692,8 +1716,10 @@ std::unique_ptr ParticipantsBoxController::createRow( && _additional.adminRights(user).has_value() && _additional.canEditAdmin(user)) { row->setActionLink(lang(lng_profile_kick)); - } else if (_role == Role::Kicked) { - row->setActionLink(lang(lng_profile_delete_removed)); + } else if (_role == Role::Kicked || _role == Role::Restricted) { + if (_additional.canRestrictUser(user)) { + row->setActionLink(lang(lng_profile_delete_removed)); + } } else if (_role == Role::Members) { if ((chat ? chat->canBanMembers() : channel->canBanMembers()) && !_additional.isCreator(user)