Skip to content

Commit 8a369f5

Browse files
committed
ensure that keys from local cache are appended to poll requests
1 parent f2cb780 commit 8a369f5

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/auth/src/platform_browser/persistence/indexed_db.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,24 +358,29 @@ class IndexedDBLocalPersistence implements InternalPersistence {
358358
return new DBPromise<DBObject[] | null>(getAllRequest).toPromise();
359359
});
360360

361-
if (!result || result.length === 0) {
361+
if (!result) {
362362
return [];
363363
}
364364

365+
console.log('result length: ', result.length);
366+
365367
// If we have pending writes in progress abort, we'll get picked up on the next poll
366368
if (this.pendingWrites !== 0) {
367369
return [];
368370
}
369371

370372
const keys = [];
371373
const keysInResult = new Set();
372-
for (const { fbase_key: key, value } of result) {
373-
keysInResult.add(key);
374-
if (JSON.stringify(this.localCache[key]) !== JSON.stringify(value)) {
375-
this.notifyListeners(key, value as PersistenceValue);
376-
keys.push(key);
374+
if (result.length !== 0) {
375+
for (const { fbase_key: key, value } of result) {
376+
keysInResult.add(key);
377+
if (JSON.stringify(this.localCache[key]) !== JSON.stringify(value)) {
378+
this.notifyListeners(key, value as PersistenceValue);
379+
keys.push(key);
380+
}
377381
}
378382
}
383+
379384
for (const localKey of Object.keys(this.localCache)) {
380385
if (this.localCache[localKey] && !keysInResult.has(localKey)) {
381386
// Deleted

0 commit comments

Comments
 (0)