diff --git a/src/lib/gramjs/sessions/StorageSession.js b/src/lib/gramjs/sessions/StorageSession.js index bb7db3355..bd87622a3 100644 --- a/src/lib/gramjs/sessions/StorageSession.js +++ b/src/lib/gramjs/sessions/StorageSession.js @@ -12,7 +12,7 @@ class StorageSession extends MemorySession { this._authKeys = {}; if (sessionInfo && sessionInfo.startsWith(SESSION_DATA_PREFIX)) { - void this._initFromSessionData(sessionInfo); + this._sessionData = sessionInfo; } else if (sessionInfo) { this._storageKey = sessionInfo; } @@ -27,6 +27,11 @@ class StorageSession extends MemorySession { } async load() { + if (this._sessionData) { + await this._loadFromSessionData(); + return; + } + if (!this._storageKey) { return; } @@ -94,8 +99,8 @@ class StorageSession extends MemorySession { void this._updateStorage(); } - async _initFromSessionData(sessionData) { - const [, mainDcIdStr, mainDcKey] = sessionData.split(':'); + async _loadFromSessionData() { + const [, mainDcIdStr, mainDcKey] = this._sessionData.split(':'); const mainDcId = Number(mainDcIdStr); const { ipAddress, diff --git a/src/modules/actions/api/initial.ts b/src/modules/actions/api/initial.ts index 0f4c2a415..753e8bbad 100644 --- a/src/modules/actions/api/initial.ts +++ b/src/modules/actions/api/initial.ts @@ -122,6 +122,7 @@ addReducer('signOut', () => { addReducer('reset', () => { localStorage.removeItem(GRAMJS_SESSION_ID_KEY); + localStorage.removeItem(LEGACY_SESSION_KEY); updateAppBadge(0); cacheApi.clear(MEDIA_CACHE_NAME);