@@ -19,7 +19,15 @@ import { CacheNode } from './view/CacheNode';
19
19
import { ChildrenNode } from './snap/ChildrenNode' ;
20
20
import { assert } from '@firebase/util' ;
21
21
import { ViewCache } from './view/ViewCache' ;
22
- import { View } from './view/View' ;
22
+ import {
23
+ View ,
24
+ viewAddEventRegistration ,
25
+ viewApplyOperation ,
26
+ viewGetCompleteServerCache ,
27
+ viewGetInitialEvents ,
28
+ viewIsEmpty ,
29
+ viewRemoveEventRegistration
30
+ } from './view/View' ;
23
31
import { Operation } from './operation/Operation' ;
24
32
import { WriteTreeRef } from './WriteTree' ;
25
33
import { Query } from '../api/Query' ;
@@ -80,13 +88,18 @@ export function syncPointApplyOperation(
80
88
if ( queryId !== null ) {
81
89
const view = syncPoint . views . get ( queryId ) ;
82
90
assert ( view != null , 'SyncTree gave us an op for an invalid query.' ) ;
83
- return view . applyOperation ( operation , writesCache , optCompleteServerCache ) ;
91
+ return viewApplyOperation (
92
+ view ,
93
+ operation ,
94
+ writesCache ,
95
+ optCompleteServerCache
96
+ ) ;
84
97
} else {
85
98
let events : Event [ ] = [ ] ;
86
99
87
100
for ( const view of syncPoint . views . values ( ) ) {
88
101
events = events . concat (
89
- view . applyOperation ( operation , writesCache , optCompleteServerCache )
102
+ viewApplyOperation ( view , operation , writesCache , optCompleteServerCache )
90
103
) ;
91
104
}
92
105
@@ -165,8 +178,8 @@ export function syncPointAddEventRegistration(
165
178
syncPoint . views . set ( query . queryIdentifier ( ) , view ) ;
166
179
}
167
180
// This is guaranteed to exist now, we just created anything that was missing
168
- view . addEventRegistration ( eventRegistration ) ;
169
- return view . getInitialEvents ( eventRegistration ) ;
181
+ viewAddEventRegistration ( view , eventRegistration ) ;
182
+ return viewGetInitialEvents ( view , eventRegistration ) ;
170
183
}
171
184
172
185
/**
@@ -193,14 +206,14 @@ export function syncPointRemoveEventRegistration(
193
206
// When you do ref.off(...), we search all views for the registration to remove.
194
207
for ( const [ viewQueryId , view ] of syncPoint . views . entries ( ) ) {
195
208
cancelEvents = cancelEvents . concat (
196
- view . removeEventRegistration ( eventRegistration , cancelError )
209
+ viewRemoveEventRegistration ( view , eventRegistration , cancelError )
197
210
) ;
198
- if ( view . isEmpty ( ) ) {
211
+ if ( viewIsEmpty ( view ) ) {
199
212
syncPoint . views . delete ( viewQueryId ) ;
200
213
201
214
// We'll deal with complete views later.
202
- if ( ! view . getQuery ( ) . getQueryParams ( ) . loadsAllData ( ) ) {
203
- removed . push ( view . getQuery ( ) ) ;
215
+ if ( ! view . query . getQueryParams ( ) . loadsAllData ( ) ) {
216
+ removed . push ( view . query ) ;
204
217
}
205
218
}
206
219
}
@@ -209,14 +222,14 @@ export function syncPointRemoveEventRegistration(
209
222
const view = syncPoint . views . get ( queryId ) ;
210
223
if ( view ) {
211
224
cancelEvents = cancelEvents . concat (
212
- view . removeEventRegistration ( eventRegistration , cancelError )
225
+ viewRemoveEventRegistration ( view , eventRegistration , cancelError )
213
226
) ;
214
- if ( view . isEmpty ( ) ) {
227
+ if ( viewIsEmpty ( view ) ) {
215
228
syncPoint . views . delete ( queryId ) ;
216
229
217
230
// We'll deal with complete views later.
218
- if ( ! view . getQuery ( ) . getQueryParams ( ) . loadsAllData ( ) ) {
219
- removed . push ( view . getQuery ( ) ) ;
231
+ if ( ! view . query . getQueryParams ( ) . loadsAllData ( ) ) {
232
+ removed . push ( view . query ) ;
220
233
}
221
234
}
222
235
}
@@ -235,7 +248,7 @@ export function syncPointRemoveEventRegistration(
235
248
export function syncPointGetQueryViews ( syncPoint : SyncPoint ) : View [ ] {
236
249
const result = [ ] ;
237
250
for ( const view of syncPoint . views . values ( ) ) {
238
- if ( ! view . getQuery ( ) . getQueryParams ( ) . loadsAllData ( ) ) {
251
+ if ( ! view . query . getQueryParams ( ) . loadsAllData ( ) ) {
239
252
result . push ( view ) ;
240
253
}
241
254
}
@@ -252,7 +265,7 @@ export function syncPointGetCompleteServerCache(
252
265
) : Node | null {
253
266
let serverCache : Node | null = null ;
254
267
for ( const view of syncPoint . views . values ( ) ) {
255
- serverCache = serverCache || view . getCompleteServerCache ( path ) ;
268
+ serverCache = serverCache || viewGetCompleteServerCache ( view , path ) ;
256
269
}
257
270
return serverCache ;
258
271
}
@@ -283,7 +296,7 @@ export function syncPointHasCompleteView(syncPoint: SyncPoint): boolean {
283
296
284
297
export function syncPointGetCompleteView ( syncPoint : SyncPoint ) : View | null {
285
298
for ( const view of syncPoint . views . values ( ) ) {
286
- if ( view . getQuery ( ) . getQueryParams ( ) . loadsAllData ( ) ) {
299
+ if ( view . query . getQueryParams ( ) . loadsAllData ( ) ) {
287
300
return view ;
288
301
}
289
302
}
0 commit comments