File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
packages/firestore/src/remote Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -297,7 +297,7 @@ export class WatchChangeAggregator {
297
297
298
298
/** Processes and adds the WatchTargetChange to the current set of changes. */
299
299
handleTargetChange ( targetChange : WatchTargetChange ) : void {
300
- targetChange . targetIds . forEach ( targetId => {
300
+ this . forEachTargetId ( targetChange , targetId => {
301
301
const targetState = this . ensureTargetState ( targetId ) ;
302
302
switch ( targetChange . state ) {
303
303
case WatchTargetChangeState . NoChange :
@@ -352,6 +352,24 @@ export class WatchChangeAggregator {
352
352
} ) ;
353
353
}
354
354
355
+ /**
356
+ * Iterates over all targetIds that the watch change applies to: either the
357
+ * targetIds explicitly listed in the change or the targetIds of all currently
358
+ * active targets.
359
+ */
360
+ forEachTargetId (
361
+ targetChange : WatchTargetChange ,
362
+ fn : ( targetId : TargetId ) => void
363
+ ) : void {
364
+ if ( targetChange . targetIds . length > 0 ) {
365
+ targetChange . targetIds . forEach ( fn ) ;
366
+ } else {
367
+ objUtils . forEachNumber ( this . targetStates , ( targetId , _ ) => {
368
+ fn ( targetId ) ;
369
+ } ) ;
370
+ }
371
+ }
372
+
355
373
/**
356
374
* Handles existence filters and synthesizes deletes for filter mismatches.
357
375
* Targets that are invalidated by filter mismatches are added to
You can’t perform that action at this time.
0 commit comments