Skip to content

Commit af30849

Browse files
Comment fixes
1 parent 37ecd7a commit af30849

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

packages/firestore/src/local/indexeddb_schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ export class DbRemoteDocument {
447447
constructor(
448448
/**
449449
* Set to an instance of DbUnknownDocument if the data for a document is
450-
* not known, but yet we no the document exist (e.g. it had a successful
451-
* update applied to it)
450+
* not known, but it is known that a document exist at the specified version
451+
* (e.g. it had a successful update applied to it)
452452
*/
453453
public unknownDocument: DbUnknownDocument | null | undefined,
454454
/**

packages/firestore/src/local/local_serializer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,23 @@ export class LocalSerializer {
7171
if (maybeDoc instanceof Document) {
7272
const doc = this.remoteSerializer.toDocument(maybeDoc);
7373
const hasCommittedMutations = maybeDoc.hasCommittedMutations;
74-
return new DbRemoteDocument(null, null, doc, hasCommittedMutations);
74+
return new DbRemoteDocument(/* unknownDocument= */null, /* noDocument= */null, doc, hasCommittedMutations);
7575
} else if (maybeDoc instanceof NoDocument) {
7676
const path = maybeDoc.key.path.toArray();
7777
const readTime = this.toDbTimestamp(maybeDoc.version);
7878
return new DbRemoteDocument(
79-
null,
79+
/* unknownDocument= */null,
8080
new DbNoDocument(path, readTime),
81-
null,
81+
/* document= */null,
8282
/* hasCommittedMutations= */ false
8383
);
8484
} else if (maybeDoc instanceof UnknownDocument) {
8585
const path = maybeDoc.key.path.toArray();
8686
const readTime = this.toDbTimestamp(maybeDoc.version);
8787
return new DbRemoteDocument(
8888
new DbUnknownDocument(path, readTime),
89-
null,
90-
null,
89+
/* noDocument= */null,
90+
/* document= */null,
9191
/* hasCommittedMutations= */ false
9292
);
9393
} else {

packages/firestore/src/model/document.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export abstract class MaybeDocument {
3838
return DocumentKey.comparator(d1.key, d2.key);
3939
}
4040

41+
/**
42+
* Whether this document had a local mutation applied that has not yet been
43+
* acknowledged by Watch.
44+
*/
4145
abstract hasPendingWrites(): boolean;
4246

4347
abstract isEqual(other: MaybeDocument | null | undefined): boolean;
@@ -137,8 +141,8 @@ export class NoDocument extends MaybeDocument {
137141
}
138142

139143
/**
140-
* A class representing a document whose data is unknown (e.g. a document that
141-
* was updated without a known base version).
144+
* A class representing an existing document whose data is unknown (e.g. a
145+
* document that was updated without a known base document).
142146
*/
143147
export class UnknownDocument extends MaybeDocument {
144148
constructor(key: DocumentKey, version: SnapshotVersion) {

packages/firestore/src/model/mutation.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,20 +376,18 @@ export class PatchMutation extends Mutation {
376376
'Transform results received by PatchMutation.'
377377
);
378378

379-
const version = mutationResult.version;
380-
381379
// TODO(mcg): Relax enforcement of this precondition
382380
//
383381
// We shouldn't actually enforce the precondition since it already passed on
384382
// the backend, but we may not have a local version of the document to
385383
// patch, so we use the precondition to prevent incorrectly putting a
386384
// partial document into our cache.
387385
if (!this.precondition.isValidFor(maybeDoc)) {
388-
return new UnknownDocument(this.key, version);
386+
return new UnknownDocument(this.key, mutationResult.version);
389387
}
390388

391389
const newData = this.patchDocument(maybeDoc);
392-
return new Document(this.key, version, newData, {
390+
return new Document(this.key, mutationResult.version, newData, {
393391
hasCommittedMutations: true
394392
});
395393
}

packages/firestore/test/unit/specs/listen_spec.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describeSpec('Listens:', [], () => {
8282

8383
specTest("Doesn't include unknown documents in cached result", [], () => {
8484
const query1 = Query.atPath(path('collection'));
85-
const docA = doc(
85+
const existingDoc = doc(
8686
'collection/exists',
8787
0,
8888
{ key: 'a' },
@@ -93,7 +93,7 @@ describeSpec('Listens:', [], () => {
9393
.userPatches('collection/unknown', { key: 'b' })
9494
.userListens(query1)
9595
.expectEvents(query1, {
96-
added: [docA],
96+
added: [existingDoc],
9797
fromCache: true,
9898
hasPendingWrites: true
9999
});
@@ -378,13 +378,12 @@ describeSpec('Listens:', [], () => {
378378

379379
return (
380380
spec()
381-
// Disable GC so the cache persists across listens.
382-
.withGCEnabled(false)
383381
.userListens(query1)
384382
.watchAcksFull(query1, 1000, docAv1)
385383
.expectEvents(query1, { added: [docAv1] })
386384
.userDeletes('collection/a')
387385
.expectEvents(query1, { removed: [docAv1] })
386+
// We have a unacknowledged delete and ignore the Watch update.
388387
.watchSends({ affects: [query1] }, docAv2)
389388
.watchSnapshots(2000)
390389
// The write stream acks our delete at version 4000.

0 commit comments

Comments
 (0)