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_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<ChannelData*> channel) {
"channels.channelParticipantsNotModified received!"));
});
}).fail([=] {
channel->mgInfo->adminsLoaded = true;
_adminsRequests.remove(channel);
}).send();

View File

@ -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;
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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);
}
}