fix group admin count

This commit is contained in:
Riko Sakurauchi 2019-12-30 11:46:13 +08:00
parent 2f85d94a34
commit fe48abb061
No known key found for this signature in database
GPG Key ID: 25AC0345B92902AF
1 changed files with 22 additions and 1 deletions

View File

@ -133,6 +133,8 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
private final static int done_button = 1;
private int realAdminCount = 0;
public ChatEditActivity(Bundle args) {
super(args);
avatarDrawable = new AvatarDrawable();
@ -885,6 +887,18 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
return count;
}
private void getRealChannelAdminCount() {
TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants();
req.channel = getMessagesController().getInputChannel(chatId);
req.filter = new TLRPC.TL_channelParticipantsAdmins();
int reqId = getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response;
realAdminCount = res.count;
adminCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", res.count), R.drawable.actions_addadmin, true);
}));
getConnectionsManager().bindRequestToGuid(reqId, classGuid);
}
private void processDone() {
if (donePressed || nameTextView == null) {
return;
@ -1189,7 +1203,14 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
}
blockCell.setTextAndValueAndIcon(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), String.format("%d/%d", count, 8), R.drawable.actions_permissions, true);
}
adminCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", ChatObject.isChannel(currentChat) ? ChatObject.hasAdminRights(currentChat) ? info.admins_count : getChannelAdminCount() : getAdminCount()), R.drawable.actions_addadmin, true);
if (ChatObject.isChannel(currentChat) && !ChatObject.hasAdminRights(currentChat) && info.participants.participants.size() != info.participants_count && realAdminCount == 0) {
adminCell.setTextAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), R.drawable.actions_addadmin, true);
} else {
adminCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", ChatObject.isChannel(currentChat) ? ChatObject.hasAdminRights(currentChat) ? info.admins_count : realAdminCount == 0 ? getChannelAdminCount() : realAdminCount : getAdminCount()), R.drawable.actions_addadmin, true);
}
if (ChatObject.isChannel(currentChat) && !ChatObject.hasAdminRights(currentChat) && info.participants.participants.size() != info.participants_count) {
getRealChannelAdminCount();
}
} else {
if (isChannel) {
membersCell.setTextAndIcon(LocaleController.getString("ChannelSubscribers", R.string.ChannelSubscribers), R.drawable.actions_viewmembers, true);