mirror of https://github.com/procxx/kepka.git
some fixes in admins and participants counts requesting
This commit is contained in:
parent
4ed11ebfff
commit
04b0932780
|
@ -504,7 +504,7 @@ namespace App {
|
||||||
cdata->date = d.vdate.v;
|
cdata->date = d.vdate.v;
|
||||||
|
|
||||||
if (!(cdata->flags & MTPDchat::flag_admins_enabled) && (d.vflags.v & MTPDchat::flag_admins_enabled)) {
|
if (!(cdata->flags & MTPDchat::flag_admins_enabled) && (d.vflags.v & MTPDchat::flag_admins_enabled)) {
|
||||||
cdata->invalidateParticipants(false);
|
cdata->invalidateParticipants();
|
||||||
}
|
}
|
||||||
cdata->flags = d.vflags.v;
|
cdata->flags = d.vflags.v;
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ namespace App {
|
||||||
cdata->isForbidden = false;
|
cdata->isForbidden = false;
|
||||||
if (cdata->version < d.vversion.v) {
|
if (cdata->version < d.vversion.v) {
|
||||||
cdata->version = d.vversion.v;
|
cdata->version = d.vversion.v;
|
||||||
cdata->invalidateParticipants(false);
|
cdata->invalidateParticipants();
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case mtpc_chatForbidden: {
|
case mtpc_chatForbidden: {
|
||||||
|
@ -527,7 +527,7 @@ namespace App {
|
||||||
cdata->setPhoto(MTP_chatPhotoEmpty());
|
cdata->setPhoto(MTP_chatPhotoEmpty());
|
||||||
cdata->date = 0;
|
cdata->date = 0;
|
||||||
cdata->count = -1;
|
cdata->count = -1;
|
||||||
cdata->invalidateParticipants(false);
|
cdata->invalidateParticipants();
|
||||||
cdata->flags = 0;
|
cdata->flags = 0;
|
||||||
cdata->isForbidden = true;
|
cdata->isForbidden = true;
|
||||||
} break;
|
} break;
|
||||||
|
@ -594,7 +594,7 @@ namespace App {
|
||||||
const MTPDchatParticipantsForbidden &d(p.c_chatParticipantsForbidden());
|
const MTPDchatParticipantsForbidden &d(p.c_chatParticipantsForbidden());
|
||||||
chat = App::chat(d.vchat_id.v);
|
chat = App::chat(d.vchat_id.v);
|
||||||
chat->count = -1;
|
chat->count = -1;
|
||||||
chat->invalidateParticipants(false);
|
chat->invalidateParticipants();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_chatParticipants: {
|
case mtpc_chatParticipants: {
|
||||||
|
@ -638,7 +638,7 @@ namespace App {
|
||||||
chat->admins[user] = true;
|
chat->admins[user] = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chat->invalidateParticipants(false);
|
chat->invalidateParticipants();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -682,7 +682,9 @@ namespace App {
|
||||||
void feedParticipantAdd(const MTPDupdateChatParticipantAdd &d, bool emitPeerUpdated) {
|
void feedParticipantAdd(const MTPDupdateChatParticipantAdd &d, bool emitPeerUpdated) {
|
||||||
ChatData *chat = App::chat(d.vchat_id.v);
|
ChatData *chat = App::chat(d.vchat_id.v);
|
||||||
if (chat->version + 1 < d.vversion.v) {
|
if (chat->version + 1 < d.vversion.v) {
|
||||||
|
chat->version = d.vversion.v;
|
||||||
chat->invalidateParticipants();
|
chat->invalidateParticipants();
|
||||||
|
App::api()->requestPeer(chat);
|
||||||
if (App::main()) {
|
if (App::main()) {
|
||||||
if (emitPeerUpdated) {
|
if (emitPeerUpdated) {
|
||||||
App::main()->peerUpdated(chat);
|
App::main()->peerUpdated(chat);
|
||||||
|
@ -711,7 +713,7 @@ namespace App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chat->invalidateParticipants(false);
|
chat->invalidateParticipants();
|
||||||
chat->count++;
|
chat->count++;
|
||||||
}
|
}
|
||||||
if (App::main()) {
|
if (App::main()) {
|
||||||
|
@ -727,7 +729,9 @@ namespace App {
|
||||||
void feedParticipantDelete(const MTPDupdateChatParticipantDelete &d, bool emitPeerUpdated) {
|
void feedParticipantDelete(const MTPDupdateChatParticipantDelete &d, bool emitPeerUpdated) {
|
||||||
ChatData *chat = App::chat(d.vchat_id.v);
|
ChatData *chat = App::chat(d.vchat_id.v);
|
||||||
if (chat->version + 1 < d.vversion.v) {
|
if (chat->version + 1 < d.vversion.v) {
|
||||||
|
chat->version = d.vversion.v;
|
||||||
chat->invalidateParticipants();
|
chat->invalidateParticipants();
|
||||||
|
App::api()->requestPeer(chat);
|
||||||
if (App::main()) {
|
if (App::main()) {
|
||||||
if (emitPeerUpdated) {
|
if (emitPeerUpdated) {
|
||||||
App::main()->peerUpdated(chat);
|
App::main()->peerUpdated(chat);
|
||||||
|
@ -740,7 +744,9 @@ namespace App {
|
||||||
UserData *user = App::userLoaded(d.vuser_id.v);
|
UserData *user = App::userLoaded(d.vuser_id.v);
|
||||||
if (user) {
|
if (user) {
|
||||||
if (chat->participants.isEmpty()) {
|
if (chat->participants.isEmpty()) {
|
||||||
chat->count--;
|
if (chat->count > 0) {
|
||||||
|
chat->count--;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ChatData::Participants::iterator i = chat->participants.find(user);
|
ChatData::Participants::iterator i = chat->participants.find(user);
|
||||||
if (i != chat->participants.end()) {
|
if (i != chat->participants.end()) {
|
||||||
|
@ -771,7 +777,7 @@ namespace App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chat->invalidateParticipants(false);
|
chat->invalidateParticipants();
|
||||||
chat->count--;
|
chat->count--;
|
||||||
}
|
}
|
||||||
if (App::main()) {
|
if (App::main()) {
|
||||||
|
@ -790,12 +796,13 @@ namespace App {
|
||||||
bool badVersion = (chat->version + 1 < d.vversion.v);
|
bool badVersion = (chat->version + 1 < d.vversion.v);
|
||||||
if (badVersion) {
|
if (badVersion) {
|
||||||
chat->invalidateParticipants();
|
chat->invalidateParticipants();
|
||||||
|
App::api()->requestPeer(chat);
|
||||||
}
|
}
|
||||||
chat->version = d.vversion.v;
|
chat->version = d.vversion.v;
|
||||||
if (mtpIsTrue(d.venabled)) {
|
if (mtpIsTrue(d.venabled)) {
|
||||||
chat->flags |= MTPDchat::flag_admins_enabled;
|
chat->flags |= MTPDchat::flag_admins_enabled;
|
||||||
if (!badVersion) {
|
if (!badVersion) {
|
||||||
chat->invalidateParticipants(false);
|
chat->invalidateParticipants();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chat->flags &= ~MTPDchat::flag_admins_enabled;
|
chat->flags &= ~MTPDchat::flag_admins_enabled;
|
||||||
|
@ -811,7 +818,9 @@ namespace App {
|
||||||
void feedParticipantAdmin(const MTPDupdateChatParticipantAdmin &d, bool emitPeerUpdated) {
|
void feedParticipantAdmin(const MTPDupdateChatParticipantAdmin &d, bool emitPeerUpdated) {
|
||||||
ChatData *chat = App::chat(d.vchat_id.v);
|
ChatData *chat = App::chat(d.vchat_id.v);
|
||||||
if (chat->version + 1 < d.vversion.v) {
|
if (chat->version + 1 < d.vversion.v) {
|
||||||
|
chat->version = d.vversion.v;
|
||||||
chat->invalidateParticipants();
|
chat->invalidateParticipants();
|
||||||
|
App::api()->requestPeer(chat);
|
||||||
if (App::main()) {
|
if (App::main()) {
|
||||||
if (emitPeerUpdated) {
|
if (emitPeerUpdated) {
|
||||||
App::main()->peerUpdated(chat);
|
App::main()->peerUpdated(chat);
|
||||||
|
@ -824,12 +833,16 @@ namespace App {
|
||||||
UserData *user = App::userLoaded(d.vuser_id.v);
|
UserData *user = App::userLoaded(d.vuser_id.v);
|
||||||
if (user) {
|
if (user) {
|
||||||
if (mtpIsTrue(d.vis_admin)) {
|
if (mtpIsTrue(d.vis_admin)) {
|
||||||
chat->admins.insert(user, true);
|
if (chat->noParticipantInfo()) {
|
||||||
|
App::api()->requestFullPeer(chat);
|
||||||
|
} else {
|
||||||
|
chat->admins.insert(user, true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
chat->admins.remove(user);
|
chat->admins.remove(user);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chat->invalidateParticipants(false);
|
chat->invalidateParticipants();
|
||||||
}
|
}
|
||||||
if (App::main()) {
|
if (App::main()) {
|
||||||
if (emitPeerUpdated) {
|
if (emitPeerUpdated) {
|
||||||
|
|
|
@ -287,7 +287,7 @@ void ContactsInner::peerUpdated(PeerData *peer) {
|
||||||
}
|
}
|
||||||
if (!_chat->amIn()) {
|
if (!_chat->amIn()) {
|
||||||
App::wnd()->hideLayer();
|
App::wnd()->hideLayer();
|
||||||
} else if (!_chat->participants.isEmpty() || _chat->count <= 0) {
|
} else if (!_chat->participants.isEmpty()) {
|
||||||
for (ContactsData::iterator i = _contactsData.begin(), e = _contactsData.end(); i != e; ++i) {
|
for (ContactsData::iterator i = _contactsData.begin(), e = _contactsData.end(); i != e; ++i) {
|
||||||
delete i.value();
|
delete i.value();
|
||||||
}
|
}
|
||||||
|
@ -1645,7 +1645,11 @@ void ContactsBox::getAdminsDone(const MTPmessages_ChatFull &result) {
|
||||||
|
|
||||||
void ContactsBox::setAdminDone(UserData *user, const MTPBool &result) {
|
void ContactsBox::setAdminDone(UserData *user, const MTPBool &result) {
|
||||||
if (mtpIsTrue(result)) {
|
if (mtpIsTrue(result)) {
|
||||||
_inner.chat()->admins.insert(user, true);
|
if (_inner.chat()->noParticipantInfo()) {
|
||||||
|
App::api()->requestFullPeer(_inner.chat());
|
||||||
|
} else {
|
||||||
|
_inner.chat()->admins.insert(user, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
--_saveRequestId;
|
--_saveRequestId;
|
||||||
if (!_saveRequestId) {
|
if (!_saveRequestId) {
|
||||||
|
@ -1678,7 +1682,7 @@ bool ContactsBox::saveAdminsFail(const RPCError &error) {
|
||||||
bool ContactsBox::editAdminFail(const RPCError &error) {
|
bool ContactsBox::editAdminFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return true;
|
if (mtpIsFlood(error)) return true;
|
||||||
--_saveRequestId;
|
--_saveRequestId;
|
||||||
_inner.chat()->invalidateParticipants(false);
|
_inner.chat()->invalidateParticipants();
|
||||||
if (!_saveRequestId) onClose();
|
if (!_saveRequestId) onClose();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2979,11 +2979,9 @@ void MentionsDropdown::updateFiltered(bool toDown) {
|
||||||
if (_filter.at(0) == '@' && _chat) {
|
if (_filter.at(0) == '@' && _chat) {
|
||||||
QMultiMap<int32, UserData*> ordered;
|
QMultiMap<int32, UserData*> ordered;
|
||||||
rows.reserve(_chat->participants.isEmpty() ? _chat->lastAuthors.size() : _chat->participants.size());
|
rows.reserve(_chat->participants.isEmpty() ? _chat->lastAuthors.size() : _chat->participants.size());
|
||||||
if (_chat->participants.isEmpty()) {
|
if (_chat->noParticipantInfo()) {
|
||||||
if (_chat->count > 0 && App::api()) {
|
if (App::api()) App::api()->requestFullPeer(_chat);
|
||||||
App::api()->requestFullPeer(_chat);
|
} else if (!_chat->participants.isEmpty()) {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (ChatData::Participants::const_iterator i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) {
|
for (ChatData::Participants::const_iterator i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) {
|
||||||
UserData *user = i.key();
|
UserData *user = i.key();
|
||||||
if (user->username.isEmpty()) continue;
|
if (user->username.isEmpty()) continue;
|
||||||
|
@ -3018,11 +3016,9 @@ void MentionsDropdown::updateFiltered(bool toDown) {
|
||||||
QMap<UserData*, bool> bots;
|
QMap<UserData*, bool> bots;
|
||||||
int32 cnt = 0;
|
int32 cnt = 0;
|
||||||
if (_chat) {
|
if (_chat) {
|
||||||
if (_chat->participants.isEmpty()) {
|
if (_chat->noParticipantInfo()) {
|
||||||
if (_chat->count > 0 && App::api()) {
|
if (App::api()) App::api()->requestFullPeer(_chat);
|
||||||
App::api()->requestFullPeer(_chat);
|
} else if (!_chat->participants.isEmpty()) {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int32 index = 0;
|
int32 index = 0;
|
||||||
for (ChatData::Participants::const_iterator i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) {
|
for (ChatData::Participants::const_iterator i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) {
|
||||||
UserData *user = i.key();
|
UserData *user = i.key();
|
||||||
|
|
|
@ -1706,7 +1706,7 @@ HistoryItem *History::addNewItem(HistoryBlock *to, bool newBlock, HistoryItem *a
|
||||||
if (lastKeyboardFrom == adding->from()->id || (!lastKeyboardInited && !peer->isChat() && !adding->out())) {
|
if (lastKeyboardFrom == adding->from()->id || (!lastKeyboardInited && !peer->isChat() && !adding->out())) {
|
||||||
clearLastKeyboard();
|
clearLastKeyboard();
|
||||||
}
|
}
|
||||||
} else if (peer->isChat() && adding->from()->isUser() && (peer->asChat()->count < 1 || !peer->asChat()->participants.isEmpty()) && !peer->asChat()->participants.contains(adding->from()->asUser())) {
|
} else if (peer->isChat() && adding->from()->isUser() && (!peer->asChat()->amIn() || !peer->asChat()->participants.isEmpty()) && !peer->asChat()->participants.contains(adding->from()->asUser())) {
|
||||||
clearLastKeyboard();
|
clearLastKeyboard();
|
||||||
} else {
|
} else {
|
||||||
lastKeyboardInited = true;
|
lastKeyboardInited = true;
|
||||||
|
@ -1914,7 +1914,7 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
|
||||||
}
|
}
|
||||||
if (!(markupFlags & MTPDreplyKeyboardMarkup_flag_ZERO)) {
|
if (!(markupFlags & MTPDreplyKeyboardMarkup_flag_ZERO)) {
|
||||||
if (!lastKeyboardInited) {
|
if (!lastKeyboardInited) {
|
||||||
if (wasKeyboardHide || ((peer->asChat()->count < 1 || !peer->asChat()->participants.isEmpty()) && item->from()->isUser() && !peer->asChat()->participants.contains(item->from()->asUser()))) {
|
if (wasKeyboardHide || ((!peer->asChat()->amIn() || !peer->asChat()->participants.isEmpty()) && item->from()->isUser() && !peer->asChat()->participants.contains(item->from()->asUser()))) {
|
||||||
clearLastKeyboard();
|
clearLastKeyboard();
|
||||||
} else {
|
} else {
|
||||||
lastKeyboardInited = true;
|
lastKeyboardInited = true;
|
||||||
|
|
|
@ -5944,7 +5944,7 @@ void HistoryWidget::peerUpdated(PeerData *data) {
|
||||||
updateListSize();
|
updateListSize();
|
||||||
if (_peer->isChannel()) updateReportSpamStatus();
|
if (_peer->isChannel()) updateReportSpamStatus();
|
||||||
if (App::api()) {
|
if (App::api()) {
|
||||||
if (data->isChat() && data->asChat()->count > 0 && data->asChat()->participants.isEmpty()) {
|
if (data->isChat() && data->asChat()->noParticipantInfo()) {
|
||||||
App::api()->requestFullPeer(data);
|
App::api()->requestFullPeer(data);
|
||||||
} else if (data->isUser() && data->asUser()->blocked == UserBlockUnknown) {
|
} else if (data->isUser() && data->asUser()->blocked == UserBlockUnknown) {
|
||||||
App::api()->requestFullPeer(data);
|
App::api()->requestFullPeer(data);
|
||||||
|
|
|
@ -589,7 +589,7 @@ void ProfileInner::updateOnlineDisplayTimer() {
|
||||||
void ProfileInner::reorderParticipants() {
|
void ProfileInner::reorderParticipants() {
|
||||||
int32 was = _participants.size(), t = unixtime(), onlineCount = 0;
|
int32 was = _participants.size(), t = unixtime(), onlineCount = 0;
|
||||||
if (_peerChat && _peerChat->amIn()) {
|
if (_peerChat && _peerChat->amIn()) {
|
||||||
if (_peerChat->count <= 0 || !_peerChat->participants.isEmpty()) {
|
if (!_peerChat->participants.isEmpty()) {
|
||||||
_participants.clear();
|
_participants.clear();
|
||||||
for (ParticipantsData::iterator i = _participantsData.begin(), e = _participantsData.end(); i != e; ++i) {
|
for (ParticipantsData::iterator i = _participantsData.begin(), e = _participantsData.end(); i != e; ++i) {
|
||||||
if (*i) {
|
if (*i) {
|
||||||
|
@ -620,7 +620,7 @@ void ProfileInner::reorderParticipants() {
|
||||||
++onlineCount;
|
++onlineCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_peerChat->count > 0 && _participants.isEmpty()) {
|
if (_peerChat->noParticipantInfo()) {
|
||||||
if (App::api()) App::api()->requestFullPeer(_peer);
|
if (App::api()) App::api()->requestFullPeer(_peer);
|
||||||
if (_onlineText.isEmpty()) _onlineText = lng_chat_status_members(lt_count, _peerChat->count);
|
if (_onlineText.isEmpty()) _onlineText = lng_chat_status_members(lt_count, _peerChat->count);
|
||||||
} else if (onlineCount && !onlyMe) {
|
} else if (onlineCount && !onlyMe) {
|
||||||
|
@ -811,7 +811,7 @@ void ProfileInner::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// participants
|
// participants
|
||||||
if (_peerChat && (_peerChat->count > 0 || !_participants.isEmpty())) {
|
if (_peerChat && _peerChat->amIn()) {
|
||||||
QString sectionHeader = lang(_participants.isEmpty() ? lng_profile_loading : lng_profile_participants_section);
|
QString sectionHeader = lang(_participants.isEmpty() ? lng_profile_loading : lng_profile_participants_section);
|
||||||
p.setFont(st::profileHeaderFont->f);
|
p.setFont(st::profileHeaderFont->f);
|
||||||
p.setPen(st::profileHeaderColor->p);
|
p.setPen(st::profileHeaderColor->p);
|
||||||
|
@ -1209,7 +1209,7 @@ void ProfileInner::resizeEvent(QResizeEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// participants
|
// participants
|
||||||
if (_peerChat && (_peerChat->count > 0 || !_participants.isEmpty())) {
|
if (_peerChat && _peerChat->amIn()) {
|
||||||
top += st::profileHeaderSkip;
|
top += st::profileHeaderSkip;
|
||||||
if (!_participants.isEmpty()) {
|
if (!_participants.isEmpty()) {
|
||||||
int32 fullCnt = _participants.size();
|
int32 fullCnt = _participants.size();
|
||||||
|
@ -1321,7 +1321,7 @@ int32 ProfileInner::countMinHeight() {
|
||||||
h = _deleteConversation.y() + _deleteConversation.height() + st::profileHeaderSkip;
|
h = _deleteConversation.y() + _deleteConversation.height() + st::profileHeaderSkip;
|
||||||
if (!_participants.isEmpty()) {
|
if (!_participants.isEmpty()) {
|
||||||
h += st::profileHeaderSkip + _participants.size() * _pHeight;
|
h += st::profileHeaderSkip + _participants.size() * _pHeight;
|
||||||
} else if (_peerChat->count > 0) {
|
} else if (_peerChat->amIn()) {
|
||||||
h += st::profileHeaderSkip;
|
h += st::profileHeaderSkip;
|
||||||
}
|
}
|
||||||
} else if (_peerChannel) {
|
} else if (_peerChannel) {
|
||||||
|
|
|
@ -375,12 +375,14 @@ public:
|
||||||
ChatData(const PeerId &id) : PeerData(id), inputChat(MTP_int(bareId())), count(0), date(0), version(0), creator(0), inviterForSpamReport(0), flags(0), isForbidden(false), botStatus(0) {
|
ChatData(const PeerId &id) : PeerData(id), inputChat(MTP_int(bareId())), count(0), date(0), version(0), creator(0), inviterForSpamReport(0), flags(0), isForbidden(false), botStatus(0) {
|
||||||
}
|
}
|
||||||
void setPhoto(const MTPChatPhoto &photo, const PhotoId &phId = UnknownPeerPhotoId);
|
void setPhoto(const MTPChatPhoto &photo, const PhotoId &phId = UnknownPeerPhotoId);
|
||||||
void invalidateParticipants(bool invalidateCount = true) {
|
void invalidateParticipants() {
|
||||||
participants = ChatData::Participants();
|
participants = ChatData::Participants();
|
||||||
admins = ChatData::Admins();
|
admins = ChatData::Admins();
|
||||||
invitedByMe = ChatData::InvitedByMe();
|
invitedByMe = ChatData::InvitedByMe();
|
||||||
botStatus = 0;
|
botStatus = 0;
|
||||||
if (invalidateCount) count = 0;
|
}
|
||||||
|
bool noParticipantInfo() const {
|
||||||
|
return (count > 0 || amIn()) && participants.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
MTPint inputChat;
|
MTPint inputChat;
|
||||||
|
|
Loading…
Reference in New Issue