@@ -75,8 +75,7 @@ const LOG_TAG = 'IndexedDbPersistence';
75
75
76
76
/**
77
77
* Oldest acceptable age in milliseconds for client metadata before the client
78
- * is considered inactive and its associated data (such as the remote document
79
- * cache changelog) is garbage collected.
78
+ * is considered inactive and its associated data is garbage collected.
80
79
*/
81
80
const MAX_CLIENT_AGE_MS = 30 * 60 * 1000 ; // 30 minutes
82
81
@@ -259,7 +258,7 @@ export class IndexedDbPersistence implements Persistence {
259
258
/** The client metadata refresh task. */
260
259
private clientMetadataRefresher : CancelablePromise < void > | null = null ;
261
260
262
- /** The last time we garbage collected the Remote Document Changelog . */
261
+ /** The last time we garbage collected the client metadata object store . */
263
262
private lastGarbageCollectionTime = Number . NEGATIVE_INFINITY ;
264
263
265
264
/** Whether to allow shared multi-tab access to the persistence layer. */
@@ -304,8 +303,7 @@ export class IndexedDbPersistence implements Persistence {
304
303
this . indexManager = new IndexedDbIndexManager ( ) ;
305
304
this . remoteDocumentCache = new IndexedDbRemoteDocumentCache (
306
305
this . serializer ,
307
- this . indexManager ,
308
- /*keepDocumentChangeLog=*/ this . allowTabSynchronization
306
+ this . indexManager
309
307
) ;
310
308
if ( platform . window && platform . window . localStorage ) {
311
309
this . window = platform . window ;
@@ -430,8 +428,7 @@ export class IndexedDbPersistence implements Persistence {
430
428
this . clientId ,
431
429
Date . now ( ) ,
432
430
this . networkEnabled ,
433
- this . inForeground ,
434
- this . remoteDocumentCache . lastProcessedDocumentChangeId
431
+ this . inForeground
435
432
)
436
433
)
437
434
. next ( ( ) => {
@@ -506,46 +503,22 @@ export class IndexedDbPersistence implements Persistence {
506
503
DbClientMetadata
507
504
> ( txn , DbClientMetadata . store ) ;
508
505
509
- return metadataStore
510
- . loadAll ( )
511
- . next ( existingClients => {
512
- activeClients = this . filterActiveClients (
513
- existingClients ,
514
- MAX_CLIENT_AGE_MS
515
- ) ;
516
- inactiveClients = existingClients . filter (
517
- client => activeClients . indexOf ( client ) === - 1
518
- ) ;
519
- } )
520
- . next ( ( ) =>
521
- // Delete metadata for clients that are no longer considered active.
522
- PersistencePromise . forEach (
523
- inactiveClients ,
524
- ( inactiveClient : DbClientMetadata ) =>
525
- metadataStore . delete ( inactiveClient . clientId )
526
- )
527
- )
528
- . next ( ( ) => {
529
- // Retrieve the minimum change ID from the set of active clients.
530
-
531
- // The primary client doesn't read from the document change log,
532
- // and hence we exclude it when we determine the minimum
533
- // `lastProcessedDocumentChangeId`.
534
- activeClients = activeClients . filter (
535
- client => client . clientId !== this . clientId
536
- ) ;
506
+ return metadataStore . loadAll ( ) . next ( existingClients => {
507
+ activeClients = this . filterActiveClients (
508
+ existingClients ,
509
+ MAX_CLIENT_AGE_MS
510
+ ) ;
511
+ inactiveClients = existingClients . filter (
512
+ client => activeClients . indexOf ( client ) === - 1
513
+ ) ;
537
514
538
- if ( activeClients . length > 0 ) {
539
- const processedChangeIds = activeClients . map (
540
- client => client . lastProcessedDocumentChangeId || 0
541
- ) ;
542
- const oldestChangeId = Math . min ( ...processedChangeIds ) ;
543
- return this . remoteDocumentCache . removeDocumentChangesThroughChangeId (
544
- txn ,
545
- oldestChangeId
546
- ) ;
547
- }
548
- } ) ;
515
+ // Delete metadata for clients that are no longer considered active.
516
+ return PersistencePromise . forEach (
517
+ inactiveClients ,
518
+ ( inactiveClient : DbClientMetadata ) =>
519
+ metadataStore . delete ( inactiveClient . clientId )
520
+ ) ;
521
+ } ) ;
549
522
}
550
523
) ;
551
524
0 commit comments