2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 22:55:11 +00:00

Save self to local storage map.

This commit is contained in:
John Preston
2018-09-11 17:36:09 +03:00
parent 0c8709ca5f
commit 34665cd6da
9 changed files with 313 additions and 218 deletions

View File

@@ -67,6 +67,7 @@ Messenger *Messenger::InstancePointer() {
struct Messenger::Private {
UserId authSessionUserId = 0;
QByteArray authSessionUserSerialized;
int32 authSessionUserStreamVersion = 0;
std::unique_ptr<AuthSessionSettings> storedAuthSession;
MTP::Instance::Config mtpConfig;
MTP::AuthKeysList mtpKeysToDestroy;
@@ -372,12 +373,19 @@ QByteArray Messenger::serializeMtpAuthorization() const {
void Messenger::setAuthSessionUserId(UserId userId) {
Expects(!authSession());
_private->authSessionUserId = userId;
}
void Messenger::setAuthSessionFromStorage(std::unique_ptr<AuthSessionSettings> data) {
void Messenger::setAuthSessionFromStorage(
std::unique_ptr<AuthSessionSettings> data,
QByteArray &&selfSerialized,
int32 selfStreamVersion) {
Expects(!authSession());
_private->storedAuthSession = std::move(data);
_private->authSessionUserSerialized = std::move(selfSerialized);
_private->authSessionUserStreamVersion = selfStreamVersion;
}
AuthSessionSettings *Messenger::getAuthSessionSettings() {
@@ -469,7 +477,9 @@ void Messenger::startMtp() {
MTPstring(), // restriction_reason
MTPstring(), // bot_inline_placeholder
MTPstring())); // lang_code
//Local::readUser(base::take(_private->authSessionUserSerialized));
Local::readSelf(
base::take(_private->authSessionUserSerialized),
base::take(_private->authSessionUserStreamVersion));
}
if (_private->storedAuthSession) {
if (_authSession) {
@@ -485,6 +495,11 @@ void Messenger::startMtp() {
if (!Core::UpdaterDisabled()) {
Core::UpdateChecker().setMtproto(mtp());
}
if (_authSession) {
// Skip all pending self updates so that we won't Local::writeSelf.
Notify::peerUpdatedSendDelayed();
}
}
void Messenger::destroyMtpKeys(MTP::AuthKeysList &&keys) {