2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

version 0.8.35.dev ready with some optimizations

This commit is contained in:
John Preston
2015-06-30 01:09:23 +03:00
parent 4b2fccf762
commit d57f6a973f
18 changed files with 275 additions and 110 deletions

View File

@@ -369,6 +369,7 @@ _failDifferenceTimeout(1), _lastUpdateTime(0), _cachedX(0), _cachedY(0), _backgr
connect(&_bySeqTimer, SIGNAL(timeout()), this, SLOT(getDifference()));
connect(&_byPtsTimer, SIGNAL(timeout()), this, SLOT(getDifference()));
connect(&_failDifferenceTimer, SIGNAL(timeout()), this, SLOT(getDifferenceForce()));
connect(_api, SIGNAL(fullPeerUpdated(PeerData*)), this, SIGNAL(peerUpdated(PeerData*)));
connect(this, SIGNAL(peerUpdated(PeerData*)), &history, SLOT(peerUpdated(PeerData*)));
connect(&_topBar, SIGNAL(clicked()), this, SLOT(onTopBarClick()));
connect(&history, SIGNAL(peerShown(PeerData*)), this, SLOT(onPeerShown(PeerData*)));
@@ -763,14 +764,16 @@ void MainWidget::deleteMessages(const QVector<MTPint> &ids) {
void MainWidget::deletedContact(UserData *user, const MTPcontacts_Link &result) {
const MTPDcontacts_link &d(result.c_contacts_link());
App::feedUsers(MTP_vector<MTPUser>(1, d.vuser));
App::feedUserLink(MTP_int(user->id & 0xFFFFFFFF), d.vmy_link, d.vforeign_link);
App::feedUsers(MTP_vector<MTPUser>(1, d.vuser), false);
App::feedUserLink(MTP_int(user->id & 0xFFFFFFFF), d.vmy_link, d.vforeign_link, false);
App::emitPeerUpdated();
}
void MainWidget::deleteHistoryAndContact(UserData *user, const MTPcontacts_Link &result) {
const MTPDcontacts_link &d(result.c_contacts_link());
App::feedUsers(MTP_vector<MTPUser>(1, d.vuser));
App::feedUserLink(MTP_int(user->id & 0xFFFFFFFF), d.vmy_link, d.vforeign_link);
App::feedUsers(MTP_vector<MTPUser>(1, d.vuser), false);
App::feedUserLink(MTP_int(user->id & 0xFFFFFFFF), d.vmy_link, d.vforeign_link, false);
App::emitPeerUpdated();
if ((profile && profile->peer() == user) || (overview && overview->peer() == user) || _stack.contains(user) || history.peer() == user) {
showPeer(0);
@@ -834,13 +837,13 @@ void MainWidget::checkedHistory(PeerData *peer, const MTPmessages_Messages &resu
const QVector<MTPMessage> *v = 0;
if (result.type() == mtpc_messages_messages) {
const MTPDmessages_messages &d(result.c_messages_messages());
App::feedChats(d.vchats);
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
v = &d.vmessages.c_vector().v;
} else if (result.type() == mtpc_messages_messagesSlice) {
const MTPDmessages_messagesSlice &d(result.c_messages_messagesSlice());
App::feedChats(d.vchats);
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
v = &d.vmessages.c_vector().v;
}
if (!v) return;
@@ -2090,6 +2093,7 @@ void MainWidget::sentDataReceived(uint64 randomId, const MTPmessages_SentMessage
void MainWidget::sentUpdatesReceived(const MTPUpdates &result) {
handleUpdates(result);
App::emitPeerUpdated();
}
void MainWidget::msgUpdated(PeerId peer, const HistoryItem *msg) {
@@ -2417,6 +2421,8 @@ void MainWidget::gotState(const MTPupdates_State &state) {
dialogs.loadDialogs();
updateOnline();
App::emitPeerUpdated();
}
void MainWidget::gotDifference(const MTPupdates_Difference &diff) {
@@ -2432,6 +2438,8 @@ void MainWidget::gotDifference(const MTPupdates_Difference &diff) {
noUpdatesTimer.start(NoUpdatesTimeout);
updInited = true;
App::emitPeerUpdated();
} break;
case mtpc_updates_differenceSlice: {
const MTPDupdates_differenceSlice &d(diff.c_updates_differenceSlice());
@@ -2444,6 +2452,8 @@ void MainWidget::gotDifference(const MTPupdates_Difference &diff) {
MTP_LOG(0, ("getDifference { good - after a slice of difference was received }%1").arg(cTestMode() ? " TESTMODE" : ""));
getDifference();
App::emitPeerUpdated();
} break;
case mtpc_updates_difference: {
const MTPDupdates_difference &d(diff.c_updates_difference());
@@ -2471,6 +2481,7 @@ void MainWidget::applySkippedPtsUpdates() {
}
--updSkipPtsUpdateLevel;
clearSkippedPtsUpdates();
App::emitPeerUpdated();
}
void MainWidget::clearSkippedPtsUpdates() {
@@ -2500,8 +2511,8 @@ bool MainWidget::updPtsUpdated(int pts, int ptsCount) { // return false if need
void MainWidget::feedDifference(const MTPVector<MTPUser> &users, const MTPVector<MTPChat> &chats, const MTPVector<MTPMessage> &msgs, const MTPVector<MTPUpdate> &other) {
App::wnd()->checkAutoLock();
App::feedUsers(users);
App::feedChats(chats);
App::feedUsers(users, false);
App::feedChats(chats, false);
feedMessageIds(other);
App::feedMsgs(msgs, 1);
feedUpdates(other, true);
@@ -3079,7 +3090,8 @@ void MainWidget::updateReceived(const mtpPrime *from, const mtpPrime *end) {
noUpdatesTimer.start(NoUpdatesTimeout);
handleUpdates(updates);
} catch(mtpErrorUnexpected &e) { // just some other type
App::emitPeerUpdated();
} catch (mtpErrorUnexpected &e) { // just some other type
}
}
update();
@@ -3097,8 +3109,8 @@ void MainWidget::handleUpdates(const MTPUpdates &updates) {
}
}
App::feedChats(d.vchats);
App::feedUsers(d.vusers);
App::feedUsers(d.vusers, false);
App::feedChats(d.vchats, false);
feedUpdates(d.vupdates);
updSetState(0, d.vdate.v, updQts, d.vseq.v);
@@ -3114,8 +3126,8 @@ void MainWidget::handleUpdates(const MTPUpdates &updates) {
}
}
App::feedChats(d.vchats);
App::feedUsers(d.vusers);
App::feedUsers(d.vusers, false);
App::feedChats(d.vchats, false);
feedUpdates(d.vupdates);
updSetState(0, d.vdate.v, updQts, d.vseq.v);
@@ -3308,17 +3320,17 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
case mtpc_updateChatParticipants: {
const MTPDupdateChatParticipants &d(update.c_updateChatParticipants());
App::feedParticipants(d.vparticipants, true);
App::feedParticipants(d.vparticipants, true, false);
} break;
case mtpc_updateChatParticipantAdd: {
const MTPDupdateChatParticipantAdd &d(update.c_updateChatParticipantAdd());
App::feedParticipantAdd(d);
App::feedParticipantAdd(d, false);
} break;
case mtpc_updateChatParticipantDelete: {
const MTPDupdateChatParticipantDelete &d(update.c_updateChatParticipantDelete());
App::feedParticipantDelete(d);
App::feedParticipantDelete(d, false);
} break;
case mtpc_updateUserStatus: {
@@ -3337,7 +3349,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
case mtpc_userStatusOffline: user->onlineTill = d.vstatus.c_userStatusOffline().vwas_online.v; break;
case mtpc_userStatusOnline: user->onlineTill = d.vstatus.c_userStatusOnline().vexpires.v; break;
}
if (App::main()) App::main()->peerUpdated(user);
App::markPeerUpdated(user);
}
if (d.vuser_id.v == MTP::authedId()) {
if (d.vstatus.type() == mtpc_userStatusOffline || d.vstatus.type() == mtpc_userStatusEmpty) {
@@ -3360,7 +3372,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} else {
user->setName(textOneLine(user->firstName), textOneLine(user->lastName), user->nameOrPhone, textOneLine(qs(d.vusername)));
}
if (App::main()) App::main()->peerUpdated(user);
App::markPeerUpdated(user);
}
} break;
@@ -3374,7 +3386,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
user->photosCount = -1;
user->photos.clear();
} else {
if (user->photoId) {
if (user->photoId && user->photoId != UnknownPeerPhotoId) {
if (user->photosCount > 0) ++user->photosCount;
user->photos.push_front(App::photo(user->photoId));
} else {
@@ -3382,7 +3394,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
user->photos.clear();
}
}
if (App::main()) App::main()->peerUpdated(user);
App::markPeerUpdated(user);
if (App::wnd()) App::wnd()->mediaOverviewUpdated(user);
}
} break;
@@ -3399,7 +3411,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
case mtpc_updateContactLink: {
const MTPDupdateContactLink &d(update.c_updateContactLink());
App::feedUserLink(d.vuser_id, d.vmy_link, d.vforeign_link);
App::feedUserLink(d.vuser_id, d.vmy_link, d.vforeign_link, false);
} break;
case mtpc_updateNotifySettings: {
@@ -3418,7 +3430,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
if (user) {
user->setPhone(qs(d.vphone));
user->setName(user->firstName, user->lastName, (user->contact || isServiceUser(user->id) || user->phone.isEmpty()) ? QString() : App::formatPhone(user->phone), user->username);
if (App::main()) App::main()->peerUpdated(user);
App::markPeerUpdated(user);
}
} break;