Fix session transactions for archive sessions

This commit is contained in:
Fedor Indutny 2021-05-21 09:03:01 -07:00 committed by GitHub
parent 6323dd6492
commit b878cad625
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -972,24 +972,28 @@ export class SignalProtocolStore extends EventsMixin {
}); });
} }
private async _archiveSession(entry?: SessionCacheEntry) { private async _archiveSession(entry?: SessionCacheEntry, zone?: Zone) {
if (!entry) { if (!entry) {
return; return;
} }
await this.enqueueSessionJob(entry.fromDB.id, async () => { await this.enqueueSessionJob(
const item = entry.hydrated entry.fromDB.id,
? entry.item async () => {
: await this._maybeMigrateSession(entry.fromDB); const item = entry.hydrated
? entry.item
: await this._maybeMigrateSession(entry.fromDB);
if (!item.hasCurrentState()) { if (!item.hasCurrentState()) {
return; return;
} }
item.archiveCurrentState(); item.archiveCurrentState();
await this.storeSession(entry.fromDB.id, item); await this.storeSession(entry.fromDB.id, item);
}); },
zone
);
} }
async archiveSession(encodedAddress: string): Promise<void> { async archiveSession(encodedAddress: string): Promise<void> {
@ -1037,7 +1041,7 @@ export class SignalProtocolStore extends EventsMixin {
await Promise.all( await Promise.all(
entries.map(async entry => { entries.map(async entry => {
await this._archiveSession(entry); await this._archiveSession(entry, zone);
}) })
); );
}); });