@@ -270,9 +270,6 @@ export function applyMutationToRemoteDocument(
270
270
* @param mutation - The mutation to apply.
271
271
* @param maybeDoc - The document to mutate. The input document can be null if
272
272
* the client has no knowledge of the pre-mutation state of the document.
273
- * @param baseDoc - The state of the document prior to this mutation batch. The
274
- * input document can be null if the client has no knowledge of the
275
- * pre-mutation state of the document.
276
273
* @param localWriteTime - A timestamp indicating the local write time of the
277
274
* batch this mutation is a part of.
278
275
* @returns The mutated document. The returned document may be null, but only
@@ -281,25 +278,14 @@ export function applyMutationToRemoteDocument(
281
278
export function applyMutationToLocalView (
282
279
mutation : Mutation ,
283
280
maybeDoc : MaybeDocument | null ,
284
- baseDoc : MaybeDocument | null ,
285
281
localWriteTime : Timestamp
286
282
) : MaybeDocument | null {
287
283
verifyMutationKeyMatches ( mutation , maybeDoc ) ;
288
284
289
285
if ( mutation instanceof SetMutation ) {
290
- return applySetMutationToLocalView (
291
- mutation ,
292
- maybeDoc ,
293
- localWriteTime ,
294
- baseDoc
295
- ) ;
286
+ return applySetMutationToLocalView ( mutation , maybeDoc , localWriteTime ) ;
296
287
} else if ( mutation instanceof PatchMutation ) {
297
- return applyPatchMutationToLocalView (
298
- mutation ,
299
- maybeDoc ,
300
- localWriteTime ,
301
- baseDoc
302
- ) ;
288
+ return applyPatchMutationToLocalView ( mutation , maybeDoc , localWriteTime ) ;
303
289
} else {
304
290
debugAssert (
305
291
mutation instanceof DeleteMutation ,
@@ -469,8 +455,7 @@ function applySetMutationToRemoteDocument(
469
455
function applySetMutationToLocalView (
470
456
mutation : SetMutation ,
471
457
maybeDoc : MaybeDocument | null ,
472
- localWriteTime : Timestamp ,
473
- baseDoc : MaybeDocument | null
458
+ localWriteTime : Timestamp
474
459
) : MaybeDocument | null {
475
460
if ( ! preconditionIsValidForDocument ( mutation . precondition , maybeDoc ) ) {
476
461
return maybeDoc ;
@@ -480,8 +465,7 @@ function applySetMutationToLocalView(
480
465
const transformResults = localTransformResults (
481
466
mutation . fieldTransforms ,
482
467
localWriteTime ,
483
- maybeDoc ,
484
- baseDoc
468
+ maybeDoc
485
469
) ;
486
470
newData = transformObject (
487
471
mutation . fieldTransforms ,
@@ -551,8 +535,7 @@ function applyPatchMutationToRemoteDocument(
551
535
function applyPatchMutationToLocalView (
552
536
mutation : PatchMutation ,
553
537
maybeDoc : MaybeDocument | null ,
554
- localWriteTime : Timestamp ,
555
- baseDoc : MaybeDocument | null
538
+ localWriteTime : Timestamp
556
539
) : MaybeDocument | null {
557
540
if ( ! preconditionIsValidForDocument ( mutation . precondition , maybeDoc ) ) {
558
541
return maybeDoc ;
@@ -562,8 +545,7 @@ function applyPatchMutationToLocalView(
562
545
const transformResults = localTransformResults (
563
546
mutation . fieldTransforms ,
564
547
localWriteTime ,
565
- maybeDoc ,
566
- baseDoc
548
+ maybeDoc
567
549
) ;
568
550
const newData = patchDocument ( mutation , maybeDoc , transformResults ) ;
569
551
return new Document ( mutation . key , version , newData , {
@@ -613,13 +595,14 @@ function patchObject(mutation: PatchMutation, data: ObjectValue): ObjectValue {
613
595
* containing transforms has been acknowledged by the server.
614
596
*
615
597
* @param fieldTransforms - The field transforms to apply the result to.
616
- * @param baseDoc - The document prior to applying this mutation batch.
598
+ * @param maybeDoc - The current state of the document after applying all
599
+ * previous mutations.
617
600
* @param serverTransformResults - The transform results received by the server.
618
601
* @returns The transform results list.
619
602
*/
620
603
function serverTransformResults (
621
604
fieldTransforms : FieldTransform [ ] ,
622
- baseDoc : MaybeDocument | null ,
605
+ maybeDoc : MaybeDocument | null ,
623
606
serverTransformResults : Array < ProtoValue | null >
624
607
) : ProtoValue [ ] {
625
608
const transformResults : ProtoValue [ ] = [ ] ;
@@ -633,8 +616,8 @@ function serverTransformResults(
633
616
const fieldTransform = fieldTransforms [ i ] ;
634
617
const transform = fieldTransform . transform ;
635
618
let previousValue : ProtoValue | null = null ;
636
- if ( baseDoc instanceof Document ) {
637
- previousValue = baseDoc . field ( fieldTransform . field ) ;
619
+ if ( maybeDoc instanceof Document ) {
620
+ previousValue = maybeDoc . field ( fieldTransform . field ) ;
638
621
}
639
622
transformResults . push (
640
623
applyTransformOperationToRemoteDocument (
@@ -657,14 +640,12 @@ function serverTransformResults(
657
640
* generate ServerTimestampValues).
658
641
* @param maybeDoc - The current state of the document after applying all
659
642
* previous mutations.
660
- * @param baseDoc - The document prior to applying this mutation batch.
661
643
* @returns The transform results list.
662
644
*/
663
645
function localTransformResults (
664
646
fieldTransforms : FieldTransform [ ] ,
665
647
localWriteTime : Timestamp ,
666
- maybeDoc : MaybeDocument | null ,
667
- baseDoc : MaybeDocument | null
648
+ maybeDoc : MaybeDocument | null
668
649
) : ProtoValue [ ] {
669
650
const transformResults : ProtoValue [ ] = [ ] ;
670
651
for ( const fieldTransform of fieldTransforms ) {
0 commit comments