2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

Move ApiWrap to AuthSession.

Also send all ApiWrap requests as an MTP::Sender.
Also create AuthSession only after starting MTProto.
This commit is contained in:
John Preston
2017-04-06 22:02:40 +03:00
parent 835b1801bc
commit 0d0307e175
16 changed files with 553 additions and 610 deletions

View File

@@ -925,9 +925,7 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
DEBUG_LOG(("MTP Info: user found, dc %1, uid %2").arg(dcId).arg(userId));
Messenger::Instance().setMtpMainDcId(dcId);
if (userId) {
Messenger::Instance().authSessionCreate(UserId(userId));
}
Messenger::Instance().setAuthSessionUserId(userId);
} break;
case dbiKey: {
@@ -1709,7 +1707,7 @@ void _writeUserSettings() {
recentEmojiPreloadData.push_back(qMakePair(item.first->id(), item.second));
}
}
auto userDataInstance = AuthSessionDataCache ? AuthSessionDataCache.get() : AuthSession::Exists() ? &AuthSession::Current().data() : nullptr;
auto userDataInstance = AuthSessionDataCache ? AuthSessionDataCache.get() : Messenger::Instance().getAuthSessionData();
auto userData = userDataInstance ? userDataInstance->serialize() : QByteArray();
uint32 size = 21 * (sizeof(quint32) + sizeof(qint32));
@@ -2065,12 +2063,7 @@ ReadMapState _readMap(const QByteArray &pass) {
_readUserSettings();
_readMtpData();
if (AuthSessionDataCache) {
if (AuthSession::Exists()) {
AuthSession::Current().data().copyFrom(*AuthSessionDataCache);
}
AuthSessionDataCache.reset();
}
Messenger::Instance().setAuthSessionData(std::move(AuthSessionDataCache));
LOG(("Map read time: %1").arg(getms() - ms));
if (_oldSettingsVersion < AppVersion) {