1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-02 09:10:40 +01:00

fix: read channel admin count

This commit is contained in:
luvletter2333 2022-07-27 14:41:49 +08:00
parent fd452a03ac
commit 6ccb87a96e
No known key found for this signature in database
GPG Key ID: A26A8880836E1978

View File

@ -1140,6 +1140,23 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
return count;
}
private int getChannelAdminCount() {
if (info == null || info.participants == null || info.participants.participants == null) {
return 1;
}
int count = 0;
for (int a = 0, N = info.participants.participants.size(); a < N; a++) {
TLRPC.ChatParticipant chatParticipant = info.participants.participants.get(a);
TLRPC.ChannelParticipant channelParticipant = ((TLRPC.TL_chatChannelParticipant) chatParticipant).channelParticipant;
if (channelParticipant instanceof TLRPC.TL_channelParticipantAdmin ||
channelParticipant instanceof TLRPC.TL_channelParticipantCreator) {
count++;
}
}
return count;
}
@Deprecated
private void getRealChannelAdminCount() {
TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants();
req.channel = getMessagesController().getInputChannel(chatId);
@ -1466,14 +1483,17 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
memberRequestsCell.setTextAndValue(LocaleController.getString("MemberRequests", R.string.MemberRequests), String.format("%d", info.requests_pending), logCell != null && logCell.getVisibility() == View.VISIBLE);
}
}
// NekoX: read admins count
String adminCount = "" ;
if (info.participants != null) {
if (ChatObject.isChannel(currentChat) && !ChatObject.hasAdminRights(currentChat) && info.participants.participants.size() != info.participants_count) {
getRealChannelAdminCount();
}
if (ChatObject.hasAdminRights(currentChat)) {
adminCell.setTextAndValue(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", ChatObject.isChannel(currentChat) ? info.admins_count : getAdminCount()), true);
} else {
// NekoX: read admins count
int count;
if (ChatObject.isChannel(currentChat))
count = getChannelAdminCount();
else
count = getAdminCount();
adminCell.setTextAndValue(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", count), true);
}
adminCell.setTextAndValue(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", ChatObject.isChannel(currentChat) ? info.admins_count : getAdminCount()), true);
} else {
if (isChannel) {
membersCell.setText(LocaleController.getString("ChannelSubscribers", R.string.ChannelSubscribers), true);