File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
packages/firestore/src/core Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,19 @@ import { Code, FirestoreError } from '../util/error';
34
34
35
35
import { SnapshotVersion } from './snapshot_version' ;
36
36
37
+ function nullableSnapshotVersionsEqual (
38
+ v1 : SnapshotVersion | null ,
39
+ v2 : SnapshotVersion | null
40
+ ) : boolean {
41
+ if ( v1 === v2 ) {
42
+ return true ;
43
+ } else if ( v1 === null || v2 === null ) {
44
+ return false ;
45
+ } else {
46
+ return v1 . isEqual ( v2 ) ;
47
+ }
48
+ }
49
+
37
50
/**
38
51
* Internal transaction object responsible for accumulating the mutations to
39
52
* perform and the base versions for any documents read.
@@ -127,12 +140,8 @@ export class Transaction {
127
140
}
128
141
129
142
const existingVersion = this . readVersions . get ( doc . key . toString ( ) ) ;
130
- if ( existingVersion !== undefined && existingVersion !== docVersion ) {
131
- if (
132
- docVersion == null ||
133
- existingVersion == null ||
134
- ! docVersion . isEqual ( existingVersion )
135
- ) {
143
+ if ( existingVersion !== undefined ) {
144
+ if ( ! nullableSnapshotVersionsEqual ( existingVersion , docVersion ) ) {
136
145
// This transaction will fail no matter what.
137
146
throw new FirestoreError (
138
147
Code . ABORTED ,
You can’t perform that action at this time.
0 commit comments