mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-11 08:48:14 +00:00
adding / removing lastParticipants / lastAdmins in supergroups on adding / removing users / admins
This commit is contained in:
parent
cab19a141f
commit
b38163b026
@ -633,15 +633,23 @@ void ApiWrap::kickParticipantDone(KickRequest kick, const MTPUpdates &result, mt
|
||||
int32 i = kick.first->asChannel()->mgInfo->lastParticipants.indexOf(kick.second);
|
||||
if (i >= 0) {
|
||||
kick.first->asChannel()->mgInfo->lastParticipants.removeAt(i);
|
||||
kick.first->asChannel()->mgInfo->lastAdmins.remove(kick.second);
|
||||
}
|
||||
kick.first->asChannel()->mgInfo->bots.remove(kick.second);
|
||||
if (kick.first->asChannel()->count > 1) {
|
||||
kick.first->asChannel()->count--;
|
||||
--kick.first->asChannel()->count;
|
||||
} else {
|
||||
kick.first->asChannel()->mgInfo->lastParticipantsStatus |= MegagroupInfo::LastParticipantsCountOutdated;
|
||||
kick.first->asChannel()->mgInfo->lastParticipantsCount = 0;
|
||||
}
|
||||
if (kick.first->asChannel()->mgInfo->lastAdmins.contains(kick.second)) {
|
||||
kick.first->asChannel()->mgInfo->lastAdmins.remove(kick.second);
|
||||
if (kick.first->asChannel()->adminsCount > 1) {
|
||||
--kick.first->asChannel()->adminsCount;
|
||||
}
|
||||
}
|
||||
kick.first->asChannel()->mgInfo->bots.remove(kick.second);
|
||||
if (kick.first->asChannel()->mgInfo->bots.isEmpty() && kick.first->asChannel()->mgInfo->botStatus > 0) {
|
||||
kick.first->asChannel()->mgInfo->botStatus = -1;
|
||||
}
|
||||
}
|
||||
emit fullPeerUpdated(kick.first);
|
||||
}
|
||||
|
@ -257,6 +257,18 @@ void ContactsInner::addAdminDone(const MTPUpdates &result, mtpRequestId req) {
|
||||
if (req != _addAdminRequestId) return;
|
||||
|
||||
_addAdminRequestId = 0;
|
||||
if (_addAdmin && _channel && _channel->isMegagroup()) {
|
||||
if (_channel->mgInfo->lastParticipants.indexOf(_addAdmin) < 0) {
|
||||
_channel->mgInfo->lastParticipants.push_front(_addAdmin);
|
||||
}
|
||||
_channel->mgInfo->lastAdmins.insert(_addAdmin);
|
||||
if (_addAdmin->botInfo) {
|
||||
_channel->mgInfo->bots.insert(_addAdmin);
|
||||
if (_channel->mgInfo->botStatus != 0 && _channel->mgInfo->botStatus < 2) {
|
||||
_channel->mgInfo->botStatus = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_addAdminBox) _addAdminBox->onClose();
|
||||
emit adminAdded();
|
||||
}
|
||||
|
@ -1454,7 +1454,18 @@ HistoryItem *History::createItem(HistoryBlock *block, const MTPMessage &msg, boo
|
||||
if (index >= 0) {
|
||||
peer->asChannel()->mgInfo->lastParticipants.removeAt(index);
|
||||
}
|
||||
peer->asChannel()->mgInfo->lastAdmins.remove(user);
|
||||
if (peer->asChannel()->count > 1) {
|
||||
--peer->asChannel()->count;
|
||||
} else {
|
||||
peer->asChannel()->mgInfo->lastParticipantsStatus |= MegagroupInfo::LastParticipantsCountOutdated;
|
||||
peer->asChannel()->mgInfo->lastParticipantsCount = 0;
|
||||
}
|
||||
if (peer->asChannel()->mgInfo->lastAdmins.contains(user)) {
|
||||
peer->asChannel()->mgInfo->lastAdmins.remove(user);
|
||||
if (peer->asChannel()->adminsCount > 1) {
|
||||
--peer->asChannel()->adminsCount;
|
||||
}
|
||||
}
|
||||
peer->asChannel()->mgInfo->bots.remove(user);
|
||||
if (peer->asChannel()->mgInfo->bots.isEmpty() && peer->asChannel()->mgInfo->botStatus > 0) {
|
||||
peer->asChannel()->mgInfo->botStatus = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user