@@ -191,15 +191,15 @@ export class MemoryEagerDelegate implements MemoryReferenceDelegate {
191
191
/** Tracks all documents that are active in Query views. */
192
192
private localViewReferences : ReferenceSet = new ReferenceSet ( ) ;
193
193
/** The list of documents that are potentially GCed after each transaction. */
194
- private _orphanedDocuments : Set < DocumentKey > | null = null ;
194
+ private _orphanedDocuments : Set < /* path= */ string > | null = null ;
195
195
196
196
private constructor ( private readonly persistence : MemoryPersistence ) { }
197
197
198
198
static factory ( persistence : MemoryPersistence ) : MemoryEagerDelegate {
199
199
return new MemoryEagerDelegate ( persistence ) ;
200
200
}
201
201
202
- private get orphanedDocuments ( ) : Set < DocumentKey > {
202
+ private get orphanedDocuments ( ) : Set < string > {
203
203
if ( ! this . _orphanedDocuments ) {
204
204
throw fail ( 'orphanedDocuments is only valid during a transaction.' ) ;
205
205
} else {
@@ -213,7 +213,7 @@ export class MemoryEagerDelegate implements MemoryReferenceDelegate {
213
213
key : DocumentKey
214
214
) : PersistencePromise < void > {
215
215
this . localViewReferences . addReference ( key , targetId ) ;
216
- this . orphanedDocuments . delete ( key ) ;
216
+ this . orphanedDocuments . delete ( key . toString ( ) ) ;
217
217
return PersistencePromise . resolve ( ) ;
218
218
}
219
219
@@ -223,15 +223,15 @@ export class MemoryEagerDelegate implements MemoryReferenceDelegate {
223
223
key : DocumentKey
224
224
) : PersistencePromise < void > {
225
225
this . localViewReferences . removeReference ( key , targetId ) ;
226
- this . orphanedDocuments . add ( key ) ;
226
+ this . orphanedDocuments . add ( key . toString ( ) ) ;
227
227
return PersistencePromise . resolve ( ) ;
228
228
}
229
229
230
230
markPotentiallyOrphaned (
231
231
txn : PersistenceTransaction ,
232
232
key : DocumentKey
233
233
) : PersistencePromise < void > {
234
- this . orphanedDocuments . add ( key ) ;
234
+ this . orphanedDocuments . add ( key . toString ( ) ) ;
235
235
return PersistencePromise . resolve ( ) ;
236
236
}
237
237
@@ -242,18 +242,18 @@ export class MemoryEagerDelegate implements MemoryReferenceDelegate {
242
242
const orphaned = this . localViewReferences . removeReferencesForId (
243
243
targetData . targetId
244
244
) ;
245
- orphaned . forEach ( key => this . orphanedDocuments . add ( key ) ) ;
245
+ orphaned . forEach ( key => this . orphanedDocuments . add ( key . toString ( ) ) ) ;
246
246
const cache = this . persistence . getTargetCache ( ) ;
247
247
return cache
248
248
. getMatchingKeysForTargetId ( txn , targetData . targetId )
249
249
. next ( keys => {
250
- keys . forEach ( key => this . orphanedDocuments . add ( key ) ) ;
250
+ keys . forEach ( key => this . orphanedDocuments . add ( key . toString ( ) ) ) ;
251
251
} )
252
252
. next ( ( ) => cache . removeTargetData ( txn , targetData ) ) ;
253
253
}
254
254
255
255
onTransactionStarted ( ) : void {
256
- this . _orphanedDocuments = new Set < DocumentKey > ( ) ;
256
+ this . _orphanedDocuments = new Set < string > ( ) ;
257
257
}
258
258
259
259
onTransactionCommitted (
@@ -264,7 +264,8 @@ export class MemoryEagerDelegate implements MemoryReferenceDelegate {
264
264
const changeBuffer = cache . newChangeBuffer ( ) ;
265
265
return PersistencePromise . forEach (
266
266
this . orphanedDocuments ,
267
- ( key : DocumentKey ) => {
267
+ ( path : string ) => {
268
+ const key = DocumentKey . fromPath ( path ) ;
268
269
return this . isReferenced ( txn , key ) . next ( isReferenced => {
269
270
if ( ! isReferenced ) {
270
271
changeBuffer . removeEntry ( key ) ;
@@ -283,9 +284,9 @@ export class MemoryEagerDelegate implements MemoryReferenceDelegate {
283
284
) : PersistencePromise < void > {
284
285
return this . isReferenced ( txn , key ) . next ( isReferenced => {
285
286
if ( isReferenced ) {
286
- this . orphanedDocuments . delete ( key ) ;
287
+ this . orphanedDocuments . delete ( key . toString ( ) ) ;
287
288
} else {
288
- this . orphanedDocuments . add ( key ) ;
289
+ this . orphanedDocuments . add ( key . toString ( ) ) ;
289
290
}
290
291
} ) ;
291
292
}
0 commit comments