diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 3eecaf9eed..4632b36f19 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -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); } diff --git a/Telegram/SourceFiles/boxes/contactsbox.cpp b/Telegram/SourceFiles/boxes/contactsbox.cpp index be668e709a..833054800d 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.cpp +++ b/Telegram/SourceFiles/boxes/contactsbox.cpp @@ -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(); } diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index f7550d8788..f3187d2491 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -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;