diff --git a/Telegram/SourceFiles/api/api_chat_participants.cpp b/Telegram/SourceFiles/api/api_chat_participants.cpp index aeb7bd0a6..0ee748f2b 100644 --- a/Telegram/SourceFiles/api/api_chat_participants.cpp +++ b/Telegram/SourceFiles/api/api_chat_participants.cpp @@ -439,6 +439,7 @@ void ChatParticipants::requestAdmins(not_null channel) { MTP_int(channel->session().serverConfig().chatSizeMax), MTP_long(participantsHash) )).done([=](const MTPchannels_ChannelParticipants &result) { + channel->mgInfo->adminsLoaded = true; _adminsRequests.remove(channel); result.match([&](const MTPDchannels_channelParticipants &data) { channel->owner().processUsers(data.vusers()); @@ -448,6 +449,7 @@ void ChatParticipants::requestAdmins(not_null channel) { "channels.channelParticipantsNotModified received!")); }); }).fail([=] { + channel->mgInfo->adminsLoaded = true; _adminsRequests.remove(channel); }).send(); diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index e1d09efec..4ec1fd6be 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -1505,6 +1505,11 @@ void ParticipantsBoxController::loadMoreRows() { LOG(("API Error: " "channels.channelParticipantsNotModified received!")); }); + if (_offset > 0 && _role == Role::Admins && channel->isMegagroup()) { + if (channel->mgInfo->admins.empty() && channel->mgInfo->adminsLoaded) { + channel->mgInfo->adminsLoaded = false; + } + } if (!firstLoad && !added) { _allLoaded = true; } diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index 7f5c7a52e..4285247a1 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -422,7 +422,9 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { if (_chat) { maxListSize += (_chat->participants.empty() ? _chat->lastAuthors.size() : _chat->participants.size()); } else if (_channel && _channel->isMegagroup()) { - if (!_channel->lastParticipantsRequestNeeded()) { + if (!_channel->canViewMembers()) { + maxListSize += _channel->mgInfo->admins.size(); + } else if (!_channel->lastParticipantsRequestNeeded()) { maxListSize += _channel->mgInfo->lastParticipants.size(); } } @@ -488,10 +490,22 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { --i; mrows.push_back({ i->second }); } - } else if (_channel - && _channel->isMegagroup() - && _channel->canViewMembers()) { - if (_channel->lastParticipantsRequestNeeded()) { + } else if (_channel && _channel->isMegagroup()) { + if (!_channel->canViewMembers()) { + if (!_channel->mgInfo->adminsLoaded) { + _channel->session().api().chatParticipants().requestAdmins(_channel); + } else { + mrows.reserve(mrows.size() + _channel->mgInfo->admins.size()); + for (const auto [userId, rank] : _channel->mgInfo->admins) { + if (const auto user = _channel->owner().userLoaded(userId)) { + if (user->isInaccessible()) continue; + if (!listAllSuggestions && filterNotPassedByName(user)) continue; + if (indexOfInFirstN(mrows, user, recentInlineBots) >= 0) continue; + mrows.push_back({ user }); + } + } + } + } else if (_channel->lastParticipantsRequestNeeded()) { _channel->session().api().chatParticipants().requestLast( _channel); } else { diff --git a/Telegram/SourceFiles/data/data_channel.h b/Telegram/SourceFiles/data/data_channel.h index 9817da915..6c05d5c88 100644 --- a/Telegram/SourceFiles/data/data_channel.h +++ b/Telegram/SourceFiles/data/data_channel.h @@ -116,6 +116,7 @@ public: QString creatorRank; int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other bool joinedMessageFound = false; + bool adminsLoaded = false; StickerSetIdentifier stickerSet; enum LastParticipantsStatus { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index d69117441..6c71cd83a 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -7495,7 +7495,7 @@ void HistoryWidget::handlePeerUpdate() { if (!channel->mgInfo->botStatus) { session().api().chatParticipants().requestBots(channel); } - if (channel->mgInfo->admins.empty()) { + if (!channel->mgInfo->adminsLoaded) { session().api().chatParticipants().requestAdmins(channel); } }