@@ -424,16 +424,6 @@ function mutationVerifyKeyMatches(
424
424
) ;
425
425
}
426
426
427
- /**
428
- * Returns the version from the given document for use as the result of a
429
- * mutation. Mutations are defined to return the version of the base document
430
- * only if it is an existing document. Deleted and unknown documents have a
431
- * post-mutation version of SnapshotVersion.min().
432
- */
433
- function getPostMutationVersion ( document : MutableDocument ) : SnapshotVersion {
434
- return document . isFoundDocument ( ) ? document . version : SnapshotVersion . min ( ) ;
435
- }
436
-
437
427
/**
438
428
* A mutation that creates or replaces the document at the given key with the
439
429
* object value contents.
@@ -491,7 +481,7 @@ function setMutationApplyToLocalView(
491
481
) ;
492
482
newData . setAll ( transformResults ) ;
493
483
document
494
- . convertToFoundDocument ( getPostMutationVersion ( document ) , newData )
484
+ . convertToFoundDocument ( document . version , newData )
495
485
. setHasLocalMutations ( ) ;
496
486
// SetMutation overwrites all fields.
497
487
return null ;
@@ -570,7 +560,7 @@ function patchMutationApplyToLocalView(
570
560
newData . setAll ( getPatch ( mutation ) ) ;
571
561
newData . setAll ( transformResults ) ;
572
562
document
573
- . convertToFoundDocument ( getPostMutationVersion ( document ) , newData )
563
+ . convertToFoundDocument ( document . version , newData )
574
564
. setHasLocalMutations ( ) ;
575
565
576
566
if ( previousMask === null ) {
@@ -709,9 +699,7 @@ function deleteMutationApplyToLocalView(
709
699
'Can only apply mutation to document with same key'
710
700
) ;
711
701
if ( preconditionIsValidForDocument ( mutation . precondition , document ) ) {
712
- // We don't call `setHasLocalMutations()` since we want to be backwards
713
- // compatible with the existing SDK behavior.
714
- document . convertToNoDocument ( SnapshotVersion . min ( ) ) ;
702
+ document . convertToNoDocument ( document . version ) . setHasLocalMutations ( ) ;
715
703
return null ;
716
704
}
717
705
return previousMask ;
0 commit comments