2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Save recent requester userIds from API.

This commit is contained in:
John Preston
2021-10-27 09:57:37 +04:00
parent f839c7f2bb
commit 36271d6b85
5 changed files with 61 additions and 12 deletions

View File

@@ -195,9 +195,23 @@ void ChannelData::setKickedCount(int newKickedCount) {
}
}
void ChannelData::setPendingRequestsCount(int count) {
if (_pendingRequestsCount != count) {
void ChannelData::setPendingRequestsCount(
int count,
const QVector<MTPlong> &recentRequesters) {
setPendingRequestsCount(count, ranges::views::all(
recentRequesters
) | ranges::views::transform([&](const MTPlong &value) {
return UserId(value);
}) | ranges::to_vector);
}
void ChannelData::setPendingRequestsCount(
int count,
std::vector<UserId> recentRequesters) {
if (_pendingRequestsCount != count
|| _recentRequesters != recentRequesters) {
_pendingRequestsCount = count;
_recentRequesters = std::move(recentRequesters);
session().changes().peerUpdated(this, UpdateFlag::PendingRequests);
}
}
@@ -550,7 +564,7 @@ void ChannelData::setAdminRights(ChatAdminRights rights) {
}
_adminRights.set(rights);
if (!canHaveInviteLink()) {
setPendingRequestsCount(0);
setPendingRequestsCount(0, std::vector<UserId>{});
}
if (isMegagroup()) {
const auto self = session().user();
@@ -885,7 +899,8 @@ void ApplyChannelUpdate(
channel->setThemeEmoji(qs(update.vtheme_emoticon().value_or_empty()));
channel->fullUpdated();
channel->setPendingRequestsCount(
update.vrequests_pending().value_or_empty());
update.vrequests_pending().value_or_empty(),
update.vrecent_requesters().value_or_empty());
if (canViewAdmins != channel->canViewAdmins()
|| canViewMembers != channel->canViewMembers()) {