@@ -270,9 +270,6 @@ export function applyMutationToRemoteDocument(
270270 * @param mutation - The mutation to apply.
271271 * @param maybeDoc - The document to mutate. The input document can be null if
272272 * 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.
276273 * @param localWriteTime - A timestamp indicating the local write time of the
277274 * batch this mutation is a part of.
278275 * @returns The mutated document. The returned document may be null, but only
@@ -281,25 +278,14 @@ export function applyMutationToRemoteDocument(
281278export function applyMutationToLocalView (
282279 mutation : Mutation ,
283280 maybeDoc : MaybeDocument | null ,
284- baseDoc : MaybeDocument | null ,
285281 localWriteTime : Timestamp
286282) : MaybeDocument | null {
287283 verifyMutationKeyMatches ( mutation , maybeDoc ) ;
288284
289285 if ( mutation instanceof SetMutation ) {
290- return applySetMutationToLocalView (
291- mutation ,
292- maybeDoc ,
293- localWriteTime ,
294- baseDoc
295- ) ;
286+ return applySetMutationToLocalView ( mutation , maybeDoc , localWriteTime ) ;
296287 } else if ( mutation instanceof PatchMutation ) {
297- return applyPatchMutationToLocalView (
298- mutation ,
299- maybeDoc ,
300- localWriteTime ,
301- baseDoc
302- ) ;
288+ return applyPatchMutationToLocalView ( mutation , maybeDoc , localWriteTime ) ;
303289 } else {
304290 debugAssert (
305291 mutation instanceof DeleteMutation ,
@@ -469,8 +455,7 @@ function applySetMutationToRemoteDocument(
469455function applySetMutationToLocalView (
470456 mutation : SetMutation ,
471457 maybeDoc : MaybeDocument | null ,
472- localWriteTime : Timestamp ,
473- baseDoc : MaybeDocument | null
458+ localWriteTime : Timestamp
474459) : MaybeDocument | null {
475460 if ( ! preconditionIsValidForDocument ( mutation . precondition , maybeDoc ) ) {
476461 return maybeDoc ;
@@ -480,8 +465,7 @@ function applySetMutationToLocalView(
480465 const transformResults = localTransformResults (
481466 mutation . fieldTransforms ,
482467 localWriteTime ,
483- maybeDoc ,
484- baseDoc
468+ maybeDoc
485469 ) ;
486470 newData = transformObject (
487471 mutation . fieldTransforms ,
@@ -551,8 +535,7 @@ function applyPatchMutationToRemoteDocument(
551535function applyPatchMutationToLocalView (
552536 mutation : PatchMutation ,
553537 maybeDoc : MaybeDocument | null ,
554- localWriteTime : Timestamp ,
555- baseDoc : MaybeDocument | null
538+ localWriteTime : Timestamp
556539) : MaybeDocument | null {
557540 if ( ! preconditionIsValidForDocument ( mutation . precondition , maybeDoc ) ) {
558541 return maybeDoc ;
@@ -562,8 +545,7 @@ function applyPatchMutationToLocalView(
562545 const transformResults = localTransformResults (
563546 mutation . fieldTransforms ,
564547 localWriteTime ,
565- maybeDoc ,
566- baseDoc
548+ maybeDoc
567549 ) ;
568550 const newData = patchDocument ( mutation , maybeDoc , transformResults ) ;
569551 return new Document ( mutation . key , version , newData , {
@@ -613,13 +595,14 @@ function patchObject(mutation: PatchMutation, data: ObjectValue): ObjectValue {
613595 * containing transforms has been acknowledged by the server.
614596 *
615597 * @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.
617600 * @param serverTransformResults - The transform results received by the server.
618601 * @returns The transform results list.
619602 */
620603function serverTransformResults (
621604 fieldTransforms : FieldTransform [ ] ,
622- baseDoc : MaybeDocument | null ,
605+ maybeDoc : MaybeDocument | null ,
623606 serverTransformResults : Array < ProtoValue | null >
624607) : ProtoValue [ ] {
625608 const transformResults : ProtoValue [ ] = [ ] ;
@@ -633,8 +616,8 @@ function serverTransformResults(
633616 const fieldTransform = fieldTransforms [ i ] ;
634617 const transform = fieldTransform . transform ;
635618 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 ) ;
638621 }
639622 transformResults . push (
640623 applyTransformOperationToRemoteDocument (
@@ -657,14 +640,12 @@ function serverTransformResults(
657640 * generate ServerTimestampValues).
658641 * @param maybeDoc - The current state of the document after applying all
659642 * previous mutations.
660- * @param baseDoc - The document prior to applying this mutation batch.
661643 * @returns The transform results list.
662644 */
663645function localTransformResults (
664646 fieldTransforms : FieldTransform [ ] ,
665647 localWriteTime : Timestamp ,
666- maybeDoc : MaybeDocument | null ,
667- baseDoc : MaybeDocument | null
648+ maybeDoc : MaybeDocument | null
668649) : ProtoValue [ ] {
669650 const transformResults : ProtoValue [ ] = [ ] ;
670651 for ( const fieldTransform of fieldTransforms ) {
0 commit comments