@@ -149,16 +149,16 @@ export class LocalDocumentsView {
149
149
memoizedOverlays : Map < DocumentKey , Overlay > ,
150
150
existenceStateChanged : DocumentKeySet
151
151
) : PersistencePromise < DocumentMap > {
152
- const results = documentMap ( ) ;
153
- const recalculateDocuments = mutableDocumentMap ( ) ;
152
+ let results = documentMap ( ) ;
153
+ let recalculateDocuments = mutableDocumentMap ( ) ;
154
154
const promises : Array < PersistencePromise < void > > = [ ] ;
155
155
docs . forEach ( ( _ , doc ) => {
156
156
const overlayPromise = memoizedOverlays . has ( doc . key )
157
157
? PersistencePromise . resolve ( memoizedOverlays . get ( doc . key ) ! )
158
158
: this . documentOverlayCache . getOverlay ( transaction , doc . key ) ;
159
159
160
160
promises . push (
161
- overlayPromise . next ( overlay => {
161
+ overlayPromise . next ( ( overlay : Overlay | null ) => {
162
162
// Recalculate an overlay if the document's existence state is changed
163
163
// due to a remote event *and* the overlay is a PatchMutation. This is
164
164
// because document existence state can change if some patch mutation's
@@ -170,7 +170,7 @@ export class LocalDocumentsView {
170
170
existenceStateChanged . has ( doc . key ) &&
171
171
( overlay == null || overlay . mutation instanceof PatchMutation )
172
172
) {
173
- recalculateDocuments . insert ( doc . key , doc ) ;
173
+ recalculateDocuments = recalculateDocuments . insert ( doc . key , doc ) ;
174
174
} else if ( overlay !== null ) {
175
175
mutationApplyToLocalView (
176
176
overlay . mutation ,
@@ -188,7 +188,9 @@ export class LocalDocumentsView {
188
188
this . recalculateAndSaveOverlays ( transaction , recalculateDocuments )
189
189
)
190
190
. next ( ( ) => {
191
- docs . forEach ( ( key , value ) => results . insert ( key , value ) ) ;
191
+ docs . forEach ( ( key , value ) => {
192
+ results = results . insert ( key , value ) ;
193
+ } ) ;
192
194
return results ;
193
195
} ) ;
194
196
}
@@ -199,7 +201,7 @@ export class LocalDocumentsView {
199
201
) : PersistencePromise < void > {
200
202
const masks = new Map < DocumentKey , FieldMask | null > ( ) ;
201
203
// A reverse lookup map from batch id to the documents within that batch.
202
- const documentsByBatchId = new SortedMap < number , Set < DocumentKey > > (
204
+ let documentsByBatchId = new SortedMap < number , Set < DocumentKey > > (
203
205
( key1 : number , key2 : number ) => key1 - key2
204
206
) ;
205
207
const processed = new Set < DocumentKey > ( ) ;
@@ -214,7 +216,10 @@ export class LocalDocumentsView {
214
216
mask = batch . applyToLocalViewWithFieldMask ( docs . get ( key ) ! , mask ) ;
215
217
masks . set ( key , mask ) ;
216
218
if ( documentsByBatchId . get ( batch . batchId ) === null ) {
217
- documentsByBatchId . insert ( batch . batchId , new Set < DocumentKey > ( ) ) ;
219
+ documentsByBatchId = documentsByBatchId . insert (
220
+ batch . batchId ,
221
+ new Set < DocumentKey > ( )
222
+ ) ;
218
223
}
219
224
documentsByBatchId . get ( batch . batchId ) ! . add ( key ) ;
220
225
} ) ;
@@ -374,7 +379,7 @@ export class LocalDocumentsView {
374
379
overlays . forEach ( overlay => {
375
380
const key = overlay . getKey ( ) ;
376
381
if ( remoteDocuments . get ( key ) === null ) {
377
- remoteDocuments . insert (
382
+ remoteDocuments = remoteDocuments . insert (
378
383
key ,
379
384
MutableDocument . newInvalidDocument ( key )
380
385
) ;
0 commit comments