Improve phrases for removed users.

This commit is contained in:
John Preston 2019-01-21 10:26:19 +04:00
parent bf85b0c109
commit 7df5df6351
4 changed files with 63 additions and 15 deletions

View File

@ -700,6 +700,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_profile_join_group" = "Join Group"; "lng_profile_join_group" = "Join Group";
"lng_profile_delete_and_exit" = "Leave"; "lng_profile_delete_and_exit" = "Leave";
"lng_profile_kick" = "Remove"; "lng_profile_kick" = "Remove";
"lng_profile_delete_removed" = "Delete";
"lng_profile_sure_kick" = "Remove {user} from the group?"; "lng_profile_sure_kick" = "Remove {user} from the group?";
"lng_profile_sure_kick_channel" = "Remove {user} from the channel?"; "lng_profile_sure_kick_channel" = "Remove {user} from the channel?";
"lng_profile_sure_remove_admin" = "Remove {user} from admins?"; "lng_profile_sure_remove_admin" = "Remove {user} from admins?";
@ -827,6 +828,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_channel_admin_status_promoted_by" = "Promoted by {user}"; "lng_channel_admin_status_promoted_by" = "Promoted by {user}";
"lng_channel_admin_status_not_admin" = "Not administrator"; "lng_channel_admin_status_not_admin" = "Not administrator";
"lng_channel_banned_status_restricted_by" = "Restricted by {user}"; "lng_channel_banned_status_restricted_by" = "Restricted by {user}";
"lng_channel_banned_status_removed_by" = "Removed by {user}";
"lng_channel_removed_list_about" = "Users removed from the channel by admins cannot rejoin it via invite links."; "lng_channel_removed_list_about" = "Users removed from the channel by admins cannot rejoin it via invite links.";
"lng_group_removed_list_about" = "Users removed from the group by admins cannot rejoin it via invite links."; "lng_group_removed_list_about" = "Users removed from the group by admins cannot rejoin it via invite links.";
@ -1229,6 +1231,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_context_edit_permissions" = "Edit permissions"; "lng_context_edit_permissions" = "Edit permissions";
"lng_context_restrict_user" = "Restrict user"; "lng_context_restrict_user" = "Restrict user";
"lng_context_remove_from_group" = "Remove from group"; "lng_context_remove_from_group" = "Remove from group";
"lng_context_add_to_group" = "Add to group";
"lng_context_copy_link" = "Copy Link"; "lng_context_copy_link" = "Copy Link";
"lng_context_copy_post_link" = "Copy Post Link"; "lng_context_copy_post_link" = "Copy Post Link";

View File

@ -1759,11 +1759,15 @@ void ApiWrap::saveDefaultRestrictions(
if (error.type() == qstr("CHAT_NOT_MODIFIED")) { if (error.type() == qstr("CHAT_NOT_MODIFIED")) {
if (const auto chat = peer->asChat()) { if (const auto chat = peer->asChat()) {
chat->setDefaultRestrictions(rights); chat->setDefaultRestrictions(rights);
if (callback) { } else if (const auto channel = peer->asChannel()) {
callback(true); channel->setDefaultRestrictions(rights);
} } else {
return; Unexpected("Peer in ApiWrap::saveDefaultRestrictions.");
} }
if (callback) {
callback(true);
}
return;
} }
if (callback) { if (callback) {
callback(false); callback(false);

View File

@ -1352,6 +1352,20 @@ base::unique_qptr<Ui::PopupMenu> ParticipantsBoxController::rowContextMenu(
result->addAction( result->addAction(
lang(lng_context_view_profile), lang(lng_context_view_profile),
crl::guard(this, [=] { _navigation->showPeerInfo(user); })); crl::guard(this, [=] { _navigation->showPeerInfo(user); }));
if (_role == Role::Kicked) {
if (_peer->isMegagroup()
&& _additional.canRestrictUser(user)) {
if (channel->canAddMembers()) {
result->addAction(
lang(lng_context_add_to_group),
crl::guard(this, [=] { unkickMember(user); }));
}
result->addAction(
lang(lng_profile_delete_removed),
crl::guard(this, [=] { removeKickedWithRow(user); }));
}
return result;
}
if (_additional.canAddOrEditAdmin(user)) { if (_additional.canAddOrEditAdmin(user)) {
const auto isAdmin = _additional.isCreator(user) const auto isAdmin = _additional.isCreator(user)
|| _additional.adminRights(user).has_value(); || _additional.adminRights(user).has_value();
@ -1369,11 +1383,13 @@ base::unique_qptr<Ui::PopupMenu> ParticipantsBoxController::rowContextMenu(
lang(lng_context_restrict_user), lang(lng_context_restrict_user),
crl::guard(this, [=] { showRestricted(user); })); crl::guard(this, [=] { showRestricted(user); }));
} }
result->addAction( if (!_additional.isKicked(user)) {
lang(isGroup result->addAction(
? lng_context_remove_from_group lang(isGroup
: lng_profile_kick), ? lng_context_remove_from_group
crl::guard(this, [=] { kickMember(user); })); : lng_profile_kick),
crl::guard(this, [=] { kickMember(user); }));
}
} }
return result; return result;
} }
@ -1528,6 +1544,15 @@ void ParticipantsBoxController::kickMember(not_null<UserData*> user) {
LayerOption::KeepOther); LayerOption::KeepOther);
} }
void ParticipantsBoxController::unkickMember(not_null<UserData*> user) {
_editBox = nullptr;
if (const auto row = delegate()->peerListFindRow(user->id)) {
delegate()->peerListRemoveRow(row);
delegate()->peerListRefreshRows();
}
_peer->session().api().addChatParticipants(_peer, { 1, user });
}
void ParticipantsBoxController::kickMemberSure(not_null<UserData*> user) { void ParticipantsBoxController::kickMemberSure(not_null<UserData*> user) {
_editBox = nullptr; _editBox = nullptr;
@ -1579,15 +1604,26 @@ void ParticipantsBoxController::removeAdminSure(not_null<UserData*> user) {
} }
} }
void ParticipantsBoxController::removeKickedWithRow(
not_null<UserData*> user) {
if (const auto row = delegate()->peerListFindRow(user->id)) {
removeKicked(row, user);
} else {
removeKicked(user);
}
}
void ParticipantsBoxController::removeKicked(not_null<UserData*> user) {
if (const auto channel = _peer->asChannel()) {
channel->session().api().unblockParticipant(channel, user);
}
}
void ParticipantsBoxController::removeKicked( void ParticipantsBoxController::removeKicked(
not_null<PeerListRow*> row, not_null<PeerListRow*> row,
not_null<UserData*> user) { not_null<UserData*> user) {
delegate()->peerListRemoveRow(row); delegate()->peerListRemoveRow(row);
delegate()->peerListRefreshRows(); delegate()->peerListRefreshRows();
removeKicked(user);
if (const auto channel = _peer->asChannel()) {
channel->session().api().unblockParticipant(channel, user);
}
} }
bool ParticipantsBoxController::appendRow(not_null<UserData*> user) { bool ParticipantsBoxController::appendRow(not_null<UserData*> user) {
@ -1651,7 +1687,7 @@ std::unique_ptr<PeerListRow> ParticipantsBoxController::createRow(
&& _additional.canEditAdmin(user)) { && _additional.canEditAdmin(user)) {
row->setActionLink(lang(lng_profile_kick)); row->setActionLink(lang(lng_profile_kick));
} else if (_role == Role::Kicked) { } else if (_role == Role::Kicked) {
row->setActionLink(lang(lng_blocked_list_unblock)); row->setActionLink(lang(lng_profile_delete_removed));
} else if (_role == Role::Members) { } else if (_role == Role::Members) {
if ((chat ? chat->canBanMembers() : channel->canBanMembers()) if ((chat ? chat->canBanMembers() : channel->canBanMembers())
&& !_additional.isCreator(user) && !_additional.isCreator(user)
@ -1704,7 +1740,9 @@ void ParticipantsBoxController::refreshCustomStatus(
} }
} else if (_role == Role::Kicked || _role == Role::Restricted) { } else if (_role == Role::Kicked || _role == Role::Restricted) {
const auto by = _additional.restrictedBy(user); const auto by = _additional.restrictedBy(user);
row->setCustomStatus(lng_channel_banned_status_restricted_by( row->setCustomStatus((_role == Role::Kicked
? lng_channel_banned_status_removed_by
: lng_channel_banned_status_restricted_by)(
lt_user, lt_user,
by ? App::peerName(by) : "Unknown")); by ? App::peerName(by) : "Unknown"));
} }

View File

@ -209,8 +209,11 @@ private:
not_null<UserData*> user, not_null<UserData*> user,
const MTPChatBannedRights &rights); const MTPChatBannedRights &rights);
void removeKicked(not_null<PeerListRow*> row, not_null<UserData*> user); void removeKicked(not_null<PeerListRow*> row, not_null<UserData*> user);
void removeKickedWithRow(not_null<UserData*> user);
void removeKicked(not_null<UserData*> user);
void kickMember(not_null<UserData*> user); void kickMember(not_null<UserData*> user);
void kickMemberSure(not_null<UserData*> user); void kickMemberSure(not_null<UserData*> user);
void unkickMember(not_null<UserData*> user);
void removeAdmin(not_null<UserData*> user); void removeAdmin(not_null<UserData*> user);
void removeAdminSure(not_null<UserData*> user); void removeAdminSure(not_null<UserData*> user);
bool appendRow(not_null<UserData*> user); bool appendRow(not_null<UserData*> user);