@@ -50,7 +50,17 @@ import {
50
50
syncPointViewExistsForQuery ,
51
51
syncPointViewForQuery
52
52
} from './SyncPoint' ;
53
- import { WriteTree , WriteTreeRef } from './WriteTree' ;
53
+ import {
54
+ WriteTree ,
55
+ writeTreeAddMerge ,
56
+ writeTreeAddOverwrite ,
57
+ writeTreeCalcCompleteEventCache ,
58
+ writeTreeChildWrites ,
59
+ writeTreeGetWrite ,
60
+ WriteTreeRef ,
61
+ writeTreeRefChild ,
62
+ writeTreeRemoveWrite
63
+ } from './WriteTree' ;
54
64
import { Query } from '../api/Query' ;
55
65
import { Node } from './snap/Node' ;
56
66
import { Event } from './view/Event' ;
@@ -141,7 +151,13 @@ export function syncTreeApplyUserOverwrite(
141
151
visible ?: boolean
142
152
) : Event [ ] {
143
153
// Record pending write.
144
- syncTree . pendingWriteTree_ . addOverwrite ( path , newData , writeId , visible ) ;
154
+ writeTreeAddOverwrite (
155
+ syncTree . pendingWriteTree_ ,
156
+ path ,
157
+ newData ,
158
+ writeId ,
159
+ visible
160
+ ) ;
145
161
146
162
if ( ! visible ) {
147
163
return [ ] ;
@@ -165,7 +181,7 @@ export function syncTreeApplyUserMerge(
165
181
writeId : number
166
182
) : Event [ ] {
167
183
// Record pending merge.
168
- syncTree . pendingWriteTree_ . addMerge ( path , changedChildren , writeId ) ;
184
+ writeTreeAddMerge ( syncTree . pendingWriteTree_ , path , changedChildren , writeId ) ;
169
185
170
186
const changeTree = ImmutableTree . fromObject ( changedChildren ) ;
171
187
@@ -186,8 +202,11 @@ export function syncTreeAckUserWrite(
186
202
writeId : number ,
187
203
revert : boolean = false
188
204
) {
189
- const write = syncTree . pendingWriteTree_ . getWrite ( writeId ) ;
190
- const needToReevaluate = syncTree . pendingWriteTree_ . removeWrite ( writeId ) ;
205
+ const write = writeTreeGetWrite ( syncTree . pendingWriteTree_ , writeId ) ;
206
+ const needToReevaluate = writeTreeRemoveWrite (
207
+ syncTree . pendingWriteTree_ ,
208
+ writeId
209
+ ) ;
191
210
if ( ! needToReevaluate ) {
192
211
return [ ] ;
193
212
} else {
@@ -522,7 +541,7 @@ export function syncTreeAddEventRegistration(
522
541
syncTree . queryToTagMap . set ( queryKey , tag ) ;
523
542
syncTree . tagToQueryMap . set ( tag , queryKey ) ;
524
543
}
525
- const writesCache = syncTree . pendingWriteTree_ . childWrites ( path ) ;
544
+ const writesCache = writeTreeChildWrites ( syncTree . pendingWriteTree_ , path ) ;
526
545
let events = syncPointAddEventRegistration (
527
546
syncPoint ,
528
547
query ,
@@ -569,7 +588,8 @@ export function syncTreeCalcCompleteEventCache(
569
588
}
570
589
}
571
590
) ;
572
- return writeTree . calcCompleteEventCache (
591
+ return writeTreeCalcCompleteEventCache (
592
+ writeTree ,
573
593
path ,
574
594
serverCache ,
575
595
writeIdsToExclude ,
@@ -602,7 +622,8 @@ export function syncTreeGetServerValue(
602
622
const serverCacheNode : CacheNode | null = serverCacheComplete
603
623
? new CacheNode ( serverCache , true , false )
604
624
: null ;
605
- const writesCache : WriteTreeRef | null = syncTree . pendingWriteTree_ . childWrites (
625
+ const writesCache : WriteTreeRef | null = writeTreeChildWrites (
626
+ syncTree . pendingWriteTree_ ,
606
627
query . path
607
628
) ;
608
629
const view : View = syncPointGetView (
@@ -636,7 +657,7 @@ function syncTreeApplyOperationToSyncPoints_(
636
657
operation ,
637
658
syncTree . syncPointTree_ ,
638
659
/*serverCache=*/ null ,
639
- syncTree . pendingWriteTree_ . childWrites ( newEmptyPath ( ) )
660
+ writeTreeChildWrites ( syncTree . pendingWriteTree_ , newEmptyPath ( ) )
640
661
) ;
641
662
}
642
663
@@ -672,7 +693,7 @@ function syncTreeApplyOperationHelper_(
672
693
const childServerCache = serverCache
673
694
? serverCache . getImmediateChild ( childName )
674
695
: null ;
675
- const childWritesCache = writesCache . child ( childName ) ;
696
+ const childWritesCache = writeTreeRefChild ( writesCache , childName ) ;
676
697
events = events . concat (
677
698
syncTreeApplyOperationHelper_ (
678
699
childOperation ,
@@ -714,7 +735,7 @@ function syncTreeApplyOperationDescendantsHelper_(
714
735
const childServerCache = serverCache
715
736
? serverCache . getImmediateChild ( childName )
716
737
: null ;
717
- const childWritesCache = writesCache . child ( childName ) ;
738
+ const childWritesCache = writeTreeRefChild ( writesCache , childName ) ;
718
739
const childOperation = operation . operationForChild ( childName ) ;
719
740
if ( childOperation ) {
720
741
events = events . concat (
@@ -823,7 +844,10 @@ function syncTreeApplyTaggedOperation_(
823
844
) : Event [ ] {
824
845
const syncPoint = syncTree . syncPointTree_ . get ( queryPath ) ;
825
846
assert ( syncPoint , "Missing sync point for query tag that we're tracking" ) ;
826
- const writesCache = syncTree . pendingWriteTree_ . childWrites ( queryPath ) ;
847
+ const writesCache = writeTreeChildWrites (
848
+ syncTree . pendingWriteTree_ ,
849
+ queryPath
850
+ ) ;
827
851
return syncPointApplyOperation ( syncPoint , operation , writesCache , null ) ;
828
852
}
829
853
0 commit comments