@@ -48,7 +48,7 @@ import {
48
48
statsManagerGetOrCreateReporter
49
49
} from './stats/StatsManager' ;
50
50
import { StatsReporter , statsReporterIncludeStat } from './stats/StatsReporter' ;
51
- import { syncPointGetView , syncPointViewExistsForQuery , syncPointViewForQuery } from './SyncPoint' ;
51
+ import { syncPointGetView , syncPointIsEmpty , syncPointViewExistsForQuery , syncPointViewForQuery } from './SyncPoint' ;
52
52
import {
53
53
createNewTag ,
54
54
SyncTree ,
@@ -483,9 +483,15 @@ export function repoGetValue(repo: Repo, query: QueryContext): Promise<Node> {
483
483
) ;
484
484
eventQueueRaiseEventsAtPath ( repo . eventQueue_ , query . _path , events ) ;
485
485
} else {
486
- // Otherwise, only overwrite for query
487
- console . log ( 'query' )
488
- syncTreeAddToPath ( query , repo . serverSyncTree_ ) ;
486
+ // Simulate `syncTreeAddEventRegistration` without events/listener setup.
487
+ // TODO: We can probably extract this.
488
+ const { syncPoint, serverCache, writesCache, serverCacheComplete, viewAlreadyExists, foundAncestorDefaultView } = syncTreeAddToPath ( query , repo . serverSyncTree_ ) ;
489
+ if ( ! viewAlreadyExists && ! foundAncestorDefaultView ) {
490
+ const view = syncPointGetView ( syncPoint , query , writesCache , serverCache , serverCacheComplete ) ;
491
+ if ( ! syncPoint . views . has ( query . _queryIdentifier ) ) {
492
+ syncPoint . views . set ( query . _queryIdentifier , view ) ;
493
+ }
494
+ }
489
495
const tag = syncTreeTagForQuery_ ( repo . serverSyncTree_ , query ) ;
490
496
const events = syncTreeApplyTaggedQueryOverwrite (
491
497
repo . serverSyncTree_ ,
@@ -494,6 +500,9 @@ export function repoGetValue(repo: Repo, query: QueryContext): Promise<Node> {
494
500
tag
495
501
) ;
496
502
eventQueueRaiseEventsAtPath ( repo . eventQueue_ , query . _path , events ) ;
503
+ // Call `syncTreeRemoveEventRegistration` with a null event registration, since there is none.
504
+ const cancels = syncTreeRemoveEventRegistration ( repo . serverSyncTree_ , query , null )
505
+ assert ( cancels . length == 0 , "unexpected cancel events in repoGetValue" ) ;
497
506
}
498
507
return Promise . resolve ( node ) ;
499
508
} ,
0 commit comments