File tree Expand file tree Collapse file tree 4 files changed +16
-24
lines changed Expand file tree Collapse file tree 4 files changed +16
-24
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ export class Transaction {
99
99
) ;
100
100
} else {
101
101
throw fail (
102
- `BatchGetDocumentsRequest returned unexpected document type : ${ doc . constructor . name } `
102
+ `BatchGetDocumentsRequest returned unexpected document: ${ doc } `
103
103
) ;
104
104
}
105
105
} ) ;
Original file line number Diff line number Diff line change @@ -141,17 +141,15 @@ class IndexedDbRemoteDocumentCacheImpl implements IndexedDbRemoteDocumentCache {
141
141
getSizedEntry (
142
142
transaction : PersistenceTransaction ,
143
143
documentKey : DocumentKey
144
- ) : PersistencePromise < DocumentSizeEntry | null > {
144
+ ) : PersistencePromise < DocumentSizeEntry > {
145
145
return remoteDocumentsStore ( transaction )
146
146
. get ( dbKey ( documentKey ) )
147
147
. next ( dbRemoteDoc => {
148
148
const doc = this . maybeDecodeDocument ( documentKey , dbRemoteDoc ) ;
149
- return doc . isValidDocument ( )
150
- ? {
151
- document : doc ,
152
- size : dbDocumentSize ( dbRemoteDoc ! )
153
- }
154
- : null ;
149
+ return {
150
+ document : doc ,
151
+ size : dbRemoteDoc ? dbDocumentSize ( dbRemoteDoc ) : 0
152
+ } ;
155
153
} ) ;
156
154
}
157
155
@@ -546,13 +544,8 @@ class IndexedDbRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuffer {
546
544
return this . documentCache
547
545
. getSizedEntry ( transaction , documentKey )
548
546
. next ( getResult => {
549
- if ( getResult === null ) {
550
- this . documentSizes . set ( documentKey , 0 ) ;
551
- return MutableDocument . newInvalidDocument ( documentKey ) ;
552
- } else {
553
- this . documentSizes . set ( documentKey , getResult . size ) ;
554
- return getResult . document ;
555
- }
547
+ this . documentSizes . set ( documentKey , getResult . size ) ;
548
+ return getResult . document ;
556
549
} ) ;
557
550
}
558
551
Original file line number Diff line number Diff line change @@ -79,10 +79,9 @@ export function fromDbRemoteDocument(
79
79
const key = DocumentKey . fromSegments ( remoteDoc . noDocument . path ) ;
80
80
const version = fromDbTimestamp ( remoteDoc . noDocument . readTime ) ;
81
81
const document = MutableDocument . newNoDocument ( key , version ) ;
82
- if ( remoteDoc . hasCommittedMutations ) {
83
- document . setHasCommittedMutations ( ) ;
84
- }
85
- return document ;
82
+ return remoteDoc . hasCommittedMutations
83
+ ? document . setHasCommittedMutations ( )
84
+ : document ;
86
85
} else if ( remoteDoc . unknownDocument ) {
87
86
const key = DocumentKey . fromSegments ( remoteDoc . unknownDocument . path ) ;
88
87
const version = fromDbTimestamp ( remoteDoc . unknownDocument . version ) ;
Original file line number Diff line number Diff line change @@ -1028,19 +1028,19 @@ function applyWriteToRemoteDocuments(
1028
1028
docKeys . forEach ( docKey => {
1029
1029
promiseChain = promiseChain
1030
1030
. next ( ( ) => documentBuffer . getEntry ( txn , docKey ) )
1031
- . next ( remoteDoc => {
1031
+ . next ( doc => {
1032
1032
const ackVersion = batchResult . docVersions . get ( docKey ) ;
1033
1033
hardAssert (
1034
1034
ackVersion !== null ,
1035
1035
'ackVersions should contain every doc in the write.'
1036
1036
) ;
1037
- if ( remoteDoc . version . compareTo ( ackVersion ! ) < 0 ) {
1038
- batch . applyToRemoteDocument ( docKey , remoteDoc , batchResult ) ;
1039
- if ( remoteDoc . isValidDocument ( ) ) {
1037
+ if ( doc . version . compareTo ( ackVersion ! ) < 0 ) {
1038
+ batch . applyToRemoteDocument ( docKey , doc , batchResult ) ;
1039
+ if ( doc . isValidDocument ( ) ) {
1040
1040
// We use the commitVersion as the readTime rather than the
1041
1041
// document's updateTime since the updateTime is not advanced
1042
1042
// for updates that do not modify the underlying document.
1043
- documentBuffer . addEntry ( remoteDoc , batchResult . commitVersion ) ;
1043
+ documentBuffer . addEntry ( doc , batchResult . commitVersion ) ;
1044
1044
}
1045
1045
}
1046
1046
} ) ;
You can’t perform that action at this time.
0 commit comments