From 503814ad4e19131f788c6b377c96ec2a224af803 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 24 Nov 2021 07:25:05 +0300 Subject: [PATCH] Slightly refactored Api::ChatParticipants. --- .../SourceFiles/api/api_chat_participants.cpp | 543 ++++++++---------- .../SourceFiles/api/api_chat_participants.h | 45 +- .../boxes/peers/edit_participants_box.cpp | 11 +- 3 files changed, 268 insertions(+), 331 deletions(-) diff --git a/Telegram/SourceFiles/api/api_chat_participants.cpp b/Telegram/SourceFiles/api/api_chat_participants.cpp index 5a6928513..15eda68ee 100644 --- a/Telegram/SourceFiles/api/api_chat_participants.cpp +++ b/Telegram/SourceFiles/api/api_chat_participants.cpp @@ -35,6 +35,16 @@ constexpr auto kMaxUsersPerInvite = 100; // that was added to this chat. constexpr auto kForwardMessagesOnAdd = 100; +[[nodiscard]] PeerId TLToPeerId(const MTPChannelParticipant &p) { + return p.match([](const MTPDchannelParticipantBanned &data) { + return peerFromMTP(data.vpeer()); + }, [](const MTPDchannelParticipantLeft &data) { + return peerFromMTP(data.vpeer()); + }, [](const auto &data) { + return peerFromUser(data.vuser_id()); + }); +} + void ApplyMegagroupAdmins( not_null channel, const MTPDchannels_channelParticipants &data) { @@ -61,14 +71,7 @@ void ApplyMegagroupAdmins( auto admins = ranges::make_subrange( list.begin(), list.end() ) | ranges::views::transform([](const MTPChannelParticipant &p) { - const auto participantId = p.match([]( - const MTPDchannelParticipantBanned &data) { - return peerFromMTP(data.vpeer()); - }, [](const MTPDchannelParticipantLeft &data) { - return peerFromMTP(data.vpeer()); - }, [](const auto &data) { - return peerFromUser(data.vuser_id()); - }); + const auto participantId = TLToPeerId(p); const auto rank = p.match([](const MTPDchannelParticipantAdmin &data) { return qs(data.vrank().value_or_empty()); }, [](const MTPDchannelParticipantCreator &data) { @@ -108,56 +111,12 @@ void ApplyMegagroupAdmins( } } -} // namespace - -ChatParticipants::ChatParticipants(not_null api) -: _session(&api->session()) -, _api(&api->instance()) { -} - -void ChatParticipants::requestForAdd( +void RefreshChannelAdmins( not_null channel, - Fn callback) { - _channelMembersForAddCallback = std::move(callback); - if (_channelMembersForAdd == channel) { - return; - } - _api.request(base::take(_channelMembersForAddRequestId)).cancel(); - - const auto offset = 0; - const auto participantsHash = uint64(0); - - _channelMembersForAdd = channel; - _channelMembersForAddRequestId = _api.request(MTPchannels_GetParticipants( - channel->inputChannel, - MTP_channelParticipantsRecent(), - MTP_int(offset), - MTP_int(_session->serverConfig().chatSizeMax), - MTP_long(participantsHash) - )).done([=](const MTPchannels_ChannelParticipants &result) { - base::take(_channelMembersForAddRequestId); - base::take(_channelMembersForAdd); - base::take(_channelMembersForAddCallback)(result); - }).fail([=](const MTP::Error &error) { - base::take(_channelMembersForAddRequestId); - base::take(_channelMembersForAdd); - base::take(_channelMembersForAddCallback); - }).send(); -} - -void ChatParticipants::refreshChannelAdmins( - not_null channel, - const QVector &participants) { + ChatParticipants::TLMembersList participants) { Data::ChannelAdminChanges changes(channel); for (const auto &p : participants) { - const auto participantId = p.match([]( - const MTPDchannelParticipantBanned &data) { - return peerFromMTP(data.vpeer()); - }, [](const MTPDchannelParticipantLeft &data) { - return peerFromMTP(data.vpeer()); - }, [](const auto &data) { - return peerFromUser(data.vuser_id()); - }); + const auto participantId = TLToPeerId(p); const auto userId = peerToUser(participantId); p.match([&](const MTPDchannelParticipantAdmin &data) { Assert(peerIsUser(participantId)); @@ -178,229 +137,24 @@ void ChatParticipants::refreshChannelAdmins( } } -void ChatParticipants::requestLast(not_null channel) { - if (!channel->isMegagroup() - || _participantsRequests.contains(channel)) { - return; - } - - const auto offset = 0; - const auto participantsHash = uint64(0); - const auto requestId = _api.request(MTPchannels_GetParticipants( - channel->inputChannel, - MTP_channelParticipantsRecent(), - MTP_int(offset), - MTP_int(_session->serverConfig().chatSizeMax), - MTP_long(participantsHash) - )).done([=](const MTPchannels_ChannelParticipants &result) { - _participantsRequests.remove(channel); - parse(channel, result, [&]( - int availableCount, - const QVector &list) { - applyLastList( - channel, - availableCount, - list); - }); - }).fail([this, channel](const MTP::Error &error) { - _participantsRequests.remove(channel); - }).send(); - - _participantsRequests[channel] = requestId; -} - -void ChatParticipants::requestBots(not_null channel) { - if (!channel->isMegagroup() || _botsRequests.contains(channel)) { - return; - } - - const auto offset = 0; - const auto participantsHash = uint64(0); - const auto requestId = _api.request(MTPchannels_GetParticipants( - channel->inputChannel, - MTP_channelParticipantsBots(), - MTP_int(offset), - MTP_int(_session->serverConfig().chatSizeMax), - MTP_long(participantsHash) - )).done([=](const MTPchannels_ChannelParticipants &result) { - _botsRequests.remove(channel); - parse(channel, result, [&]( - int availableCount, - const QVector &list) { - applyBotsList( - channel, - availableCount, - list); - }); - }).fail([=](const MTP::Error &error) { - _botsRequests.remove(channel); - }).send(); - - _botsRequests[channel] = requestId; -} - -void ChatParticipants::requestAdmins(not_null channel) { - if (!channel->isMegagroup() || _adminsRequests.contains(channel)) { - return; - } - - const auto offset = 0; - const auto participantsHash = uint64(0); - const auto requestId = _api.request(MTPchannels_GetParticipants( - channel->inputChannel, - MTP_channelParticipantsAdmins(), - MTP_int(offset), - MTP_int(_session->serverConfig().chatSizeMax), - MTP_long(participantsHash) - )).done([=](const MTPchannels_ChannelParticipants &result) { - _adminsRequests.remove(channel); - result.match([&](const MTPDchannels_channelParticipants &data) { - ApplyMegagroupAdmins(channel, data); - }, [&](const MTPDchannels_channelParticipantsNotModified &) { - LOG(("API Error: channels.channelParticipantsNotModified received!")); - }); - }).fail([=](const MTP::Error &error) { - _adminsRequests.remove(channel); - }).send(); - - _adminsRequests[channel] = requestId; -} - -void ChatParticipants::requestCountDelayed( - not_null channel) { - _participantsCountRequestTimer.call( - kReloadChannelMembersTimeout, - [=] { channel->updateFullForced(); }); -} - -void ChatParticipants::add( - not_null peer, - const std::vector> &users, - Fn done) { - if (const auto chat = peer->asChat()) { - for (const auto &user : users) { - _api.request(MTPmessages_AddChatUser( - chat->inputChat, - user->inputUser, - MTP_int(kForwardMessagesOnAdd) - )).done([=](const MTPUpdates &result) { - _session->api().applyUpdates(result); - if (done) done(true); - }).fail([=](const MTP::Error &error) { - ShowAddParticipantsError(error.type(), peer, { 1, user }); - if (done) done(false); - }).afterDelay(kSmallDelayMs).send(); - } - } else if (const auto channel = peer->asChannel()) { - const auto hasBot = ranges::any_of(users, &UserData::isBot); - if (!peer->isMegagroup() && hasBot) { - ShowAddParticipantsError("USER_BOT", peer, users); - return; - } - auto list = QVector(); - list.reserve(std::min(int(users.size()), int(kMaxUsersPerInvite))); - const auto send = [&] { - const auto callback = base::take(done); - _api.request(MTPchannels_InviteToChannel( - channel->inputChannel, - MTP_vector(list) - )).done([=](const MTPUpdates &result) { - _session->api().applyUpdates(result); - requestCountDelayed(channel); - if (callback) callback(true); - }).fail([=](const MTP::Error &error) { - ShowAddParticipantsError(error.type(), peer, users); - if (callback) callback(false); - }).afterDelay(kSmallDelayMs).send(); - }; - for (const auto &user : users) { - list.push_back(user->inputUser); - if (list.size() == kMaxUsersPerInvite) { - send(); - list.clear(); - } - } - if (!list.empty()) { - send(); - } - } else { - Unexpected("User in ChatParticipants::add."); - } -} - -void ChatParticipants::parseRecent( - not_null channel, - const MTPchannels_ChannelParticipants &result, - Fn &list)> callbackList, - Fn callbackNotModified) { - parse(channel, result, [&]( - int availableCount, - const QVector &list) { - auto applyLast = channel->isMegagroup() - && (channel->mgInfo->lastParticipants.size() <= list.size()); - if (applyLast) { - applyLastList( - channel, - availableCount, - list); - } - if (callbackList) { - callbackList(availableCount, list); - } - }, std::move(callbackNotModified)); -} - -void ChatParticipants::parse( - not_null channel, - const MTPchannels_ChannelParticipants &result, - Fn &list)> callbackList, - Fn callbackNotModified) { - result.match([&](const MTPDchannels_channelParticipants &data) { - _session->data().processUsers(data.vusers()); - if (channel->mgInfo) { - refreshChannelAdmins(channel, data.vparticipants().v); - } - if (callbackList) { - callbackList(data.vcount().v, data.vparticipants().v); - } - }, [&](const MTPDchannels_channelParticipantsNotModified &) { - if (callbackNotModified) { - callbackNotModified(); - } else { - LOG(("API Error: " - "channels.channelParticipantsNotModified received!")); - } - }); -} - -void ChatParticipants::applyLastList( +void ApplyLastList( not_null channel, int availableCount, - const QVector &list) { + ChatParticipants::TLMembersList list) { channel->mgInfo->lastAdmins.clear(); channel->mgInfo->lastRestricted.clear(); channel->mgInfo->lastParticipants.clear(); - channel->mgInfo->lastParticipantsStatus = MegagroupInfo::LastParticipantsUpToDate - | MegagroupInfo::LastParticipantsOnceReceived; + channel->mgInfo->lastParticipantsStatus = + MegagroupInfo::LastParticipantsUpToDate + | MegagroupInfo::LastParticipantsOnceReceived; auto botStatus = channel->mgInfo->botStatus; for (const auto &p : list) { - const auto participantId = p.match([]( - const MTPDchannelParticipantBanned &data) { - return peerFromMTP(data.vpeer()); - }, [](const MTPDchannelParticipantLeft &data) { - return peerFromMTP(data.vpeer()); - }, [](const auto &data) { - return peerFromUser(data.vuser_id()); - }); + const auto participantId = TLToPeerId(p); if (!participantId) { continue; } - const auto participant = _session->data().peer(participantId); + const auto participant = channel->owner().peer(participantId); const auto user = participant->asUser(); const auto adminCanEdit = (p.type() == mtpc_channelParticipantAdmin) ? p.c_channelParticipantAdmin().is_can_edit() @@ -460,21 +214,21 @@ void ChatParticipants::applyLastList( //} else { // channel->setMembersCount(availableCount); //} - _session->changes().peerUpdated( + channel->session().changes().peerUpdated( channel, (Data::PeerUpdate::Flag::Members | Data::PeerUpdate::Flag::Admins)); channel->mgInfo->botStatus = botStatus; - _session->changes().peerUpdated( + channel->session().changes().peerUpdated( channel, Data::PeerUpdate::Flag::FullInfo); } -void ChatParticipants::applyBotsList( +void ApplyBotsList( not_null channel, int availableCount, - const QVector &list) { - const auto history = _session->data().historyLoaded(channel); + ChatParticipants::TLMembersList list) { + const auto history = channel->owner().historyLoaded(channel); channel->mgInfo->bots.clear(); channel->mgInfo->botStatus = -1; @@ -482,19 +236,12 @@ void ChatParticipants::applyBotsList( auto botStatus = channel->mgInfo->botStatus; auto keyboardBotFound = !history || !history->lastKeyboardFrom; for (const auto &p : list) { - const auto participantId = p.match([]( - const MTPDchannelParticipantBanned &data) { - return peerFromMTP(data.vpeer()); - }, [](const MTPDchannelParticipantLeft &data) { - return peerFromMTP(data.vpeer()); - }, [](const auto &data) { - return peerFromUser(data.vuser_id()); - }); + const auto participantId = TLToPeerId(p); if (!participantId) { continue; } - const auto participant = _session->data().peer(participantId); + const auto participant = channel->owner().peer(participantId); const auto user = participant->asUser(); if (user && user->isBot()) { channel->mgInfo->bots.insert(user); @@ -509,18 +256,234 @@ void ChatParticipants::applyBotsList( } } if (needBotsInfos) { - _session->api().requestFullPeer(channel); + channel->session().api().requestFullPeer(channel); } if (!keyboardBotFound) { history->clearLastKeyboard(); } channel->mgInfo->botStatus = botStatus; - _session->changes().peerUpdated( + channel->session().changes().peerUpdated( channel, Data::PeerUpdate::Flag::FullInfo); } +} // namespace + +ChatParticipants::ChatParticipants(not_null api) +: _api(&api->instance()) { +} + +void ChatParticipants::requestForAdd( + not_null channel, + Fn callback) { + Expects(callback != nullptr); + _forAdd.callback = std::move(callback); + if (_forAdd.channel == channel) { + return; + } + _api.request(base::take(_forAdd.requestId)).cancel(); + + const auto offset = 0; + const auto participantsHash = uint64(0); + + _forAdd.channel = channel; + _forAdd.requestId = _api.request(MTPchannels_GetParticipants( + channel->inputChannel, + MTP_channelParticipantsRecent(), + MTP_int(offset), + MTP_int(channel->session().serverConfig().chatSizeMax), + MTP_long(participantsHash) + )).done([=](const MTPchannels_ChannelParticipants &result) { + base::take(_forAdd).callback(result); + }).fail([=](const MTP::Error &error) { + base::take(_forAdd); + }).send(); +} + +void ChatParticipants::requestLast(not_null channel) { + if (!channel->isMegagroup() + || _participantsRequests.contains(channel)) { + return; + } + + const auto offset = 0; + const auto participantsHash = uint64(0); + const auto requestId = _api.request(MTPchannels_GetParticipants( + channel->inputChannel, + MTP_channelParticipantsRecent(), + MTP_int(offset), + MTP_int(channel->session().serverConfig().chatSizeMax), + MTP_long(participantsHash) + )).done([=](const MTPchannels_ChannelParticipants &result) { + _participantsRequests.remove(channel); + parse(channel, result, [&](int availableCount, TLMembersList list) { + ApplyLastList( + channel, + availableCount, + list); + }); + }).fail([this, channel](const MTP::Error &error) { + _participantsRequests.remove(channel); + }).send(); + + _participantsRequests[channel] = requestId; +} + +void ChatParticipants::requestBots(not_null channel) { + if (!channel->isMegagroup() || _botsRequests.contains(channel)) { + return; + } + + const auto offset = 0; + const auto participantsHash = uint64(0); + const auto requestId = _api.request(MTPchannels_GetParticipants( + channel->inputChannel, + MTP_channelParticipantsBots(), + MTP_int(offset), + MTP_int(channel->session().serverConfig().chatSizeMax), + MTP_long(participantsHash) + )).done([=](const MTPchannels_ChannelParticipants &result) { + _botsRequests.remove(channel); + parse(channel, result, [&](int availableCount, TLMembersList list) { + ApplyBotsList( + channel, + availableCount, + list); + }); + }).fail([=](const MTP::Error &error) { + _botsRequests.remove(channel); + }).send(); + + _botsRequests[channel] = requestId; +} + +void ChatParticipants::requestAdmins(not_null channel) { + if (!channel->isMegagroup() || _adminsRequests.contains(channel)) { + return; + } + + const auto offset = 0; + const auto participantsHash = uint64(0); + const auto requestId = _api.request(MTPchannels_GetParticipants( + channel->inputChannel, + MTP_channelParticipantsAdmins(), + MTP_int(offset), + MTP_int(channel->session().serverConfig().chatSizeMax), + MTP_long(participantsHash) + )).done([=](const MTPchannels_ChannelParticipants &result) { + _adminsRequests.remove(channel); + result.match([&](const MTPDchannels_channelParticipants &data) { + ApplyMegagroupAdmins(channel, data); + }, [](const MTPDchannels_channelParticipantsNotModified &) { + LOG(("API Error: " + "channels.channelParticipantsNotModified received!")); + }); + }).fail([=](const MTP::Error &error) { + _adminsRequests.remove(channel); + }).send(); + + _adminsRequests[channel] = requestId; +} + +void ChatParticipants::requestCountDelayed( + not_null channel) { + _participantsCountRequestTimer.call( + kReloadChannelMembersTimeout, + [=] { channel->updateFullForced(); }); +} + +void ChatParticipants::add( + not_null peer, + const std::vector> &users, + Fn done) { + if (const auto chat = peer->asChat()) { + for (const auto &user : users) { + _api.request(MTPmessages_AddChatUser( + chat->inputChat, + user->inputUser, + MTP_int(kForwardMessagesOnAdd) + )).done([=](const MTPUpdates &result) { + chat->session().api().applyUpdates(result); + if (done) done(true); + }).fail([=](const MTP::Error &error) { + ShowAddParticipantsError(error.type(), peer, { 1, user }); + if (done) done(false); + }).afterDelay(kSmallDelayMs).send(); + } + } else if (const auto channel = peer->asChannel()) { + const auto hasBot = ranges::any_of(users, &UserData::isBot); + if (!peer->isMegagroup() && hasBot) { + ShowAddParticipantsError("USER_BOT", peer, users); + return; + } + auto list = QVector(); + list.reserve(std::min(int(users.size()), int(kMaxUsersPerInvite))); + const auto send = [&] { + const auto callback = base::take(done); + _api.request(MTPchannels_InviteToChannel( + channel->inputChannel, + MTP_vector(list) + )).done([=](const MTPUpdates &result) { + channel->session().api().applyUpdates(result); + requestCountDelayed(channel); + if (callback) callback(true); + }).fail([=](const MTP::Error &error) { + ShowAddParticipantsError(error.type(), peer, users); + if (callback) callback(false); + }).afterDelay(kSmallDelayMs).send(); + }; + for (const auto &user : users) { + list.push_back(user->inputUser); + if (list.size() == kMaxUsersPerInvite) { + send(); + list.clear(); + } + } + if (!list.empty()) { + send(); + } + } else { + Unexpected("User in ChatParticipants::add."); + } +} + +void ChatParticipants::parseRecent( + not_null channel, + const TLMembers &result, + Fn callbackList) { + parse(channel, result, [&](int availableCount, TLMembersList list) { + const auto applyLast = channel->isMegagroup() + && (channel->mgInfo->lastParticipants.size() <= list.size()); + if (applyLast) { + ApplyLastList( + channel, + availableCount, + list); + } + if (callbackList) { + callbackList(availableCount, list); + } + }); +} + +void ChatParticipants::parse( + not_null channel, + const TLMembers &result, + Fn callbackList) { + result.match([&](const MTPDchannels_channelParticipants &data) { + channel->owner().processUsers(data.vusers()); + if (channel->mgInfo) { + RefreshChannelAdmins(channel, data.vparticipants().v); + } + if (callbackList) { + callbackList(data.vcount().v, data.vparticipants().v); + } + }, [&](const MTPDchannels_channelParticipantsNotModified &) { + LOG(("API Error: channels.channelParticipantsNotModified received!")); + }); +} + void ChatParticipants::requestSelf(not_null channel) { if (_selfParticipantRequests.contains(channel)) { return; @@ -533,7 +496,7 @@ void ChatParticipants::requestSelf(not_null channel) { channel->inviter = inviter; channel->inviteDate = inviteDate; channel->inviteViaRequest = inviteViaRequest; - if (const auto history = _session->data().historyLoaded(channel)) { + if (const auto history = channel->owner().historyLoaded(channel)) { if (history->lastMessageKnown()) { history->checkLocalMessages(); history->owner().sendHistoryChangeNotifications(); @@ -549,7 +512,7 @@ void ChatParticipants::requestSelf(not_null channel) { )).done([=](const MTPchannels_ChannelParticipant &result) { _selfParticipantRequests.erase(channel); result.match([&](const MTPDchannels_channelParticipant &data) { - _session->data().processUsers(data.vusers()); + channel->owner().processUsers(data.vusers()); const auto &participant = data.vparticipant(); participant.match([&](const MTPDchannelParticipantSelf &data) { @@ -559,9 +522,9 @@ void ChatParticipants::requestSelf(not_null channel) { data.is_via_request()); }, [&](const MTPDchannelParticipantCreator &) { if (channel->mgInfo) { - channel->mgInfo->creator = _session->user(); + channel->mgInfo->creator = channel->session().user(); } - finalize(_session->userId(), channel->date); + finalize(channel->session().userId(), channel->date); }, [&](const MTPDchannelParticipantAdmin &data) { const auto inviter = data.is_self() ? data.vinviter_id().value_or(-1) @@ -597,7 +560,7 @@ void ChatParticipants::kick( chat->inputChat, participant->asUser()->inputUser )).done([=](const MTPUpdates &result) { - _session->api().applyUpdates(result); + chat->session().api().applyUpdates(result); }).send(); } @@ -617,7 +580,7 @@ void ChatParticipants::kick( MTPDchatBannedRights::Flags::from_raw(uint32(rights.flags))), MTP_int(rights.until)) )).done([=](const MTPUpdates &result) { - _session->api().applyUpdates(result); + channel->session().api().applyUpdates(result); _kickRequests.remove(KickRequest(channel, participant)); channel->applyEditBanned(participant, currentRights, rights); @@ -641,7 +604,7 @@ void ChatParticipants::unblock( participant->input, MTP_chatBannedRights(MTP_flags(0), MTP_int(0)) )).done([=](const MTPUpdates &result) { - _session->api().applyUpdates(result); + channel->session().api().applyUpdates(result); _kickRequests.remove(KickRequest(channel, participant)); if (channel->kickedCount() > 0) { diff --git a/Telegram/SourceFiles/api/api_chat_participants.h b/Telegram/SourceFiles/api/api_chat_participants.h index 6794c4db2..be07fad94 100644 --- a/Telegram/SourceFiles/api/api_chat_participants.h +++ b/Telegram/SourceFiles/api/api_chat_participants.h @@ -15,14 +15,12 @@ class ChannelData; struct ChatRestrictionsInfo; -namespace Main { -class Session; -} // namespace Main - namespace Api { class ChatParticipants final { public: + using TLMembers = MTPchannels_ChannelParticipants; + using TLMembersList = const QVector &; explicit ChatParticipants(not_null api); void requestLast(not_null channel); @@ -32,18 +30,12 @@ public: void parse( not_null channel, - const MTPchannels_ChannelParticipants &result, - Fn &list)> callbackList, - Fn callbackNotModified = nullptr); + const TLMembers &result, + Fn callbackList); void parseRecent( not_null channel, - const MTPchannels_ChannelParticipants &result, - Fn &list)> callbackList = nullptr, - Fn callbackNotModified = nullptr); + const TLMembers &result, + Fn callbackList = nullptr); void add( not_null peer, const std::vector> &users, @@ -53,7 +45,7 @@ public: void requestForAdd( not_null channel, - Fn callback); + Fn callback); void kick( not_null chat, @@ -67,20 +59,6 @@ public: not_null participant); private: - void applyLastList( - not_null channel, - int availableCount, - const QVector &list); - void applyBotsList( - not_null channel, - int availableCount, - const QVector &list); - - void refreshChannelAdmins( - not_null channel, - const QVector &participants); - - const not_null _session; MTP::Sender _api; using PeerRequests = base::flat_map; @@ -90,10 +68,11 @@ private: PeerRequests _adminsRequests; base::DelayedCallTimer _participantsCountRequestTimer; - ChannelData *_channelMembersForAdd = nullptr; - mtpRequestId _channelMembersForAddRequestId = 0; - Fn _channelMembersForAddCallback; + struct { + ChannelData *channel = nullptr; + mtpRequestId requestId = 0; + Fn callback; + } _forAdd; base::flat_set> _selfParticipantRequests; diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 59b1d0f26..92bf2a79a 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -1396,16 +1396,11 @@ void ParticipantsBoxController::loadMoreRows() { auto wasRecentRequest = firstLoad && (_role == Role::Members || _role == Role::Profile); auto parseParticipants = [&](auto &&result, auto &&callback) { + auto &api = channel->session().api().chatParticipants(); if (wasRecentRequest) { - channel->session().api().chatParticipants().parseRecent( - channel, - result, - callback); + api.parseRecent(channel, result, callback); } else { - channel->session().api().chatParticipants().parse( - channel, - result, - callback); + api.parse(channel, result, callback); } }; parseParticipants(result, [&](