Suggest group-with-hidden-members admins in mentions.

This commit is contained in:
John Preston 2023-08-11 18:12:35 +02:00
parent 027e662478
commit d52475666d
5 changed files with 28 additions and 6 deletions

View file

@ -439,6 +439,7 @@ void ChatParticipants::requestAdmins(not_null<ChannelData*> channel) {
MTP_int(channel->session().serverConfig().chatSizeMax), MTP_int(channel->session().serverConfig().chatSizeMax),
MTP_long(participantsHash) MTP_long(participantsHash)
)).done([=](const MTPchannels_ChannelParticipants &result) { )).done([=](const MTPchannels_ChannelParticipants &result) {
channel->mgInfo->adminsLoaded = true;
_adminsRequests.remove(channel); _adminsRequests.remove(channel);
result.match([&](const MTPDchannels_channelParticipants &data) { result.match([&](const MTPDchannels_channelParticipants &data) {
channel->owner().processUsers(data.vusers()); channel->owner().processUsers(data.vusers());
@ -448,6 +449,7 @@ void ChatParticipants::requestAdmins(not_null<ChannelData*> channel) {
"channels.channelParticipantsNotModified received!")); "channels.channelParticipantsNotModified received!"));
}); });
}).fail([=] { }).fail([=] {
channel->mgInfo->adminsLoaded = true;
_adminsRequests.remove(channel); _adminsRequests.remove(channel);
}).send(); }).send();

View file

@ -1505,6 +1505,11 @@ void ParticipantsBoxController::loadMoreRows() {
LOG(("API Error: " LOG(("API Error: "
"channels.channelParticipantsNotModified received!")); "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) { if (!firstLoad && !added) {
_allLoaded = true; _allLoaded = true;
} }

View file

@ -422,7 +422,9 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
if (_chat) { if (_chat) {
maxListSize += (_chat->participants.empty() ? _chat->lastAuthors.size() : _chat->participants.size()); maxListSize += (_chat->participants.empty() ? _chat->lastAuthors.size() : _chat->participants.size());
} else if (_channel && _channel->isMegagroup()) { } 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(); maxListSize += _channel->mgInfo->lastParticipants.size();
} }
} }
@ -488,10 +490,22 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
--i; --i;
mrows.push_back({ i->second }); mrows.push_back({ i->second });
} }
} else if (_channel } else if (_channel && _channel->isMegagroup()) {
&& _channel->isMegagroup() if (!_channel->canViewMembers()) {
&& _channel->canViewMembers()) { if (!_channel->mgInfo->adminsLoaded) {
if (_channel->lastParticipantsRequestNeeded()) { _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->session().api().chatParticipants().requestLast(
_channel); _channel);
} else { } else {

View file

@ -116,6 +116,7 @@ public:
QString creatorRank; QString creatorRank;
int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other
bool joinedMessageFound = false; bool joinedMessageFound = false;
bool adminsLoaded = false;
StickerSetIdentifier stickerSet; StickerSetIdentifier stickerSet;
enum LastParticipantsStatus { enum LastParticipantsStatus {

View file

@ -7495,7 +7495,7 @@ void HistoryWidget::handlePeerUpdate() {
if (!channel->mgInfo->botStatus) { if (!channel->mgInfo->botStatus) {
session().api().chatParticipants().requestBots(channel); session().api().chatParticipants().requestBots(channel);
} }
if (channel->mgInfo->admins.empty()) { if (!channel->mgInfo->adminsLoaded) {
session().api().chatParticipants().requestAdmins(channel); session().api().chatParticipants().requestAdmins(channel);
} }
} }