18
18
import { assert } from '@firebase/util' ;
19
19
20
20
import { ReferenceConstructor } from '../api/Reference' ;
21
- import { ValueEventRegistration } from '../api/Reference_impl' ;
22
21
23
22
import { AckUserWrite } from './operation/AckUserWrite' ;
24
23
import { ListenComplete } from './operation/ListenComplete' ;
@@ -30,7 +29,6 @@ import {
30
29
Operation
31
30
} from './operation/Operation' ;
32
31
import { Overwrite } from './operation/Overwrite' ;
33
- import { Repo } from './Repo' ;
34
32
import { ChildrenNode } from './snap/ChildrenNode' ;
35
33
import { Node } from './snap/Node' ;
36
34
import {
@@ -355,10 +353,12 @@ export function syncTreeRemoveEventRegistration(
355
353
cancelEvents = removedAndEvents . events ;
356
354
357
355
if ( ! skipListenerDedup ) {
358
- // We may have just removed one of many listeners and can short-circuit this whole process
359
- // We may also not have removed a default listener, in which case all of the descendant listeners should already be
360
- // properly set up.
361
- //
356
+ /**
357
+ * We may have just removed one of many listeners and can short-circuit this whole process
358
+ * We may also not have removed a default listener, in which case all of the descendant listeners should already be
359
+ * properly set up.
360
+ */
361
+
362
362
// Since indexed queries can shadow if they don't have other query constraints, check for loadsAllData(), instead of
363
363
// queryId === 'default'
364
364
const removingDefault =
@@ -387,7 +387,7 @@ export function syncTreeRemoveEventRegistration(
387
387
const listener = syncTreeCreateListenerForView_ ( syncTree , view ) ;
388
388
syncTree . listenProvider_ . startListening (
389
389
syncTreeQueryForListening_ ( newQuery ) ,
390
- syncTreeTagForQuery_ ( syncTree , newQuery ) ,
390
+ syncTreeTagForQuery ( syncTree , newQuery ) ,
391
391
listener . hashFn ,
392
392
listener . onComplete
393
393
) ;
@@ -779,7 +779,7 @@ function syncTreeCreateListenerForView_(
779
779
view : View
780
780
) : { hashFn ( ) : string ; onComplete ( a : string , b ?: unknown ) : Event [ ] } {
781
781
const query = view . query ;
782
- const tag = syncTreeTagForQuery_ ( syncTree , query ) ;
782
+ const tag = syncTreeTagForQuery ( syncTree , query ) ;
783
783
784
784
return {
785
785
hashFn : ( ) => {
@@ -811,7 +811,7 @@ function syncTreeCreateListenerForView_(
811
811
/**
812
812
* Return the tag associated with the given query.
813
813
*/
814
- export function syncTreeTagForQuery_ (
814
+ export function syncTreeTagForQuery (
815
815
syncTree : SyncTree ,
816
816
query : QueryContext
817
817
) : number | null {
@@ -943,7 +943,7 @@ function syncTreeSetupListener_(
943
943
view : View
944
944
) : Event [ ] {
945
945
const path = query . _path ;
946
- const tag = syncTreeTagForQuery_ ( syncTree , query ) ;
946
+ const tag = syncTreeTagForQuery ( syncTree , query ) ;
947
947
const listener = syncTreeCreateListenerForView_ ( syncTree , view ) ;
948
948
949
949
const events = syncTree . listenProvider_ . startListening (
@@ -992,49 +992,9 @@ function syncTreeSetupListener_(
992
992
const queryToStop = queriesToStop [ i ] ;
993
993
syncTree . listenProvider_ . stopListening (
994
994
syncTreeQueryForListening_ ( queryToStop ) ,
995
- syncTreeTagForQuery_ ( syncTree , queryToStop )
995
+ syncTreeTagForQuery ( syncTree , queryToStop )
996
996
) ;
997
997
}
998
998
}
999
999
return events ;
1000
1000
}
1001
-
1002
- /**
1003
- * Added to support non-listener data queries (Used by `get()`).
1004
- * Simulates `onValue` `onlyOnce` where it adds the event registration,
1005
- * and then applies the changes to the tree.
1006
- * @param repo - repo reference to the overall Repo.
1007
- * @param query - query to be added.
1008
- * @param node - Data needed to be added to the tree
1009
- * @param eventRegistration - a dummy event registration to add to the SyncTree
1010
- */
1011
- export function syncTreeAddGetRegistration (
1012
- repo : Repo ,
1013
- query : QueryContext ,
1014
- node : Node ,
1015
- eventRegistration : ValueEventRegistration
1016
- ) {
1017
- syncTreeAddEventRegistration (
1018
- repo . serverSyncTree_ ,
1019
- query ,
1020
- eventRegistration ,
1021
- true
1022
- ) ;
1023
- let events : Event [ ] ;
1024
- if ( query . _queryParams . loadsAllData ( ) ) {
1025
- events = syncTreeApplyServerOverwrite (
1026
- repo . serverSyncTree_ ,
1027
- query . _path ,
1028
- node
1029
- ) ;
1030
- } else {
1031
- const tag = syncTreeTagForQuery_ ( repo . serverSyncTree_ , query ) ;
1032
- events = syncTreeApplyTaggedQueryOverwrite (
1033
- repo . serverSyncTree_ ,
1034
- query . _path ,
1035
- node ,
1036
- tag
1037
- ) ;
1038
- }
1039
- return events ;
1040
- }
0 commit comments