Skip to content

Commit aee3d0c

Browse files
Almost address feedback
1 parent 5448dff commit aee3d0c

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

packages/firestore/src/local/indexeddb_persistence.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,10 +1225,7 @@ export class IndexedDbLruDelegate implements ReferenceDelegate, LruDelegate {
12251225
// Our size accounting requires us to read all documents before
12261226
// removing them.
12271227
return changeBuffer.getEntry(txn, docKey).next(() => {
1228-
changeBuffer.removeEntry(
1229-
docKey,
1230-
SnapshotVersion.forDeletedDoc()
1231-
);
1228+
changeBuffer.removeEntry(docKey);
12321229
return documentTargetStore(txn).delete(sentinelKey(docKey));
12331230
});
12341231
}

packages/firestore/src/local/indexeddb_remote_document_cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class IndexedDbRemoteDocumentCache implements RemoteDocumentCache {
110110
}
111111

112112
/**
113-
* Updates the current size.
113+
* Updates the current cache size.
114114
*
115115
* Callers to `addEntry()` and `removeEntry()` *must* call this afterwards to update the
116116
* cache's metadata.

packages/firestore/src/local/memory_persistence.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export class MemoryEagerDelegate implements ReferenceDelegate {
277277
(key: DocumentKey) => {
278278
return this.isReferenced(txn, key).next(isReferenced => {
279279
if (!isReferenced) {
280-
changeBuffer.removeEntry(key, SnapshotVersion.forDeletedDoc());
280+
changeBuffer.removeEntry(key);
281281
}
282282
});
283283
}
@@ -417,7 +417,7 @@ export class MemoryLruDelegate implements ReferenceDelegate, LruDelegate {
417417
return this.isPinned(txn, key, upperBound).next(isPinned => {
418418
if (!isPinned) {
419419
count++;
420-
changeBuffer.removeEntry(key, SnapshotVersion.forDeletedDoc());
420+
changeBuffer.removeEntry(key);
421421
}
422422
});
423423
});

packages/firestore/src/local/remote_document_change_buffer.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export abstract class RemoteDocumentChangeBuffer {
8080
protected get readTime(): SnapshotVersion {
8181
assert(
8282
this._readTime !== undefined,
83-
'Read time is not set. Did you call addEntry/removeEntry?'
83+
'Read time is not set. All removeEntry() calls must include a readTime if `trackRemovals` is used.'
8484
);
8585
return this._readTime!;
8686
}
@@ -103,9 +103,11 @@ export abstract class RemoteDocumentChangeBuffer {
103103
* You can only remove documents that have already been retrieved via
104104
* `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).
105105
*/
106-
removeEntry(key: DocumentKey, readTime: SnapshotVersion): void {
106+
removeEntry(key: DocumentKey, readTime?: SnapshotVersion): void {
107107
this.assertNotApplied();
108-
this.readTime = readTime;
108+
if (readTime) {
109+
this.readTime = readTime;
110+
}
109111
this.changes.set(key, null);
110112
}
111113

packages/firestore/test/unit/local/remote_document_change_buffer.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('RemoteDocumentChangeBuffer', () => {
7373
const newADoc = doc('coll/a', 43, { new: 'data' });
7474
buffer.addEntry(newADoc, newADoc.version);
7575
expect(await buffer.getEntry(key('coll/a'))).to.not.be.null;
76-
buffer.removeEntry(newADoc.key, newADoc.version);
76+
buffer.removeEntry(newADoc.key);
7777
expect(await buffer.getEntry(key('coll/a'))).to.be.null;
7878
});
7979

@@ -94,7 +94,7 @@ describe('RemoteDocumentChangeBuffer', () => {
9494

9595
it('can apply changes with removal', async () => {
9696
expectEqual(await buffer.getEntry(key('coll/a')), INITIAL_DOC);
97-
buffer.removeEntry(INITIAL_DOC.key, INITIAL_DOC.version);
97+
buffer.removeEntry(INITIAL_DOC.key);
9898
// Reading directly against the cache should still yield the old result.
9999
expectEqual(await cache.getEntry(key('coll/a')), INITIAL_DOC);
100100

packages/firestore/test/unit/local/test_remote_document_change_buffer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export class TestRemoteDocumentChangeBuffer {
3535
this.buffer.addEntry(maybeDocument, readTime);
3636
}
3737

38-
removeEntry(key: DocumentKey, readTime: SnapshotVersion): void {
39-
this.buffer.removeEntry(key, readTime);
38+
removeEntry(key: DocumentKey): void {
39+
this.buffer.removeEntry(key);
4040
}
4141

4242
getEntry(documentKey: DocumentKey): Promise<MaybeDocument | null> {

0 commit comments

Comments
 (0)