Skip to content

Commit 73c5947

Browse files
Factor out Multi-Tab code
1 parent 6a4c00f commit 73c5947

20 files changed

+457
-452
lines changed

packages/firestore/src/core/component_provider.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import {
2121
SharedClientState,
2222
WebStorageSharedClientState
2323
} from '../local/shared_client_state';
24-
import { LocalStore } from '../local/local_store';
25-
import { SyncEngine } from './sync_engine';
24+
import { LocalStore, MultiTabLocalStore } from '../local/local_store';
25+
import { MultiTabSyncEngine, SyncEngine } from './sync_engine';
2626
import { RemoteStore } from '../remote/remote_store';
2727
import { EventManager } from './event_manager';
2828
import { AsyncQueue } from '../util/async_queue';
@@ -77,8 +77,8 @@ export interface ComponentProvider {
7777
export class IndexedDbComponentProvider implements ComponentProvider {
7878
persistence!: IndexedDbPersistence;
7979
sharedClientState!: SharedClientState;
80-
localStore!: LocalStore;
81-
syncEngine!: SyncEngine;
80+
localStore!: MultiTabLocalStore;
81+
syncEngine!: MultiTabSyncEngine;
8282
gcScheduler!: GarbageCollectionScheduler | null;
8383
remoteStore!: RemoteStore;
8484
eventManager!: EventManager;
@@ -141,7 +141,7 @@ export class IndexedDbComponentProvider implements ComponentProvider {
141141
.garbageCollector;
142142

143143
this.gcScheduler = new LruScheduler(garbageCollector, asyncQueue);
144-
this.localStore = new LocalStore(
144+
this.localStore = new MultiTabLocalStore(
145145
this.persistence,
146146
new IndexFreeQueryEngine(),
147147
initialUser
@@ -157,7 +157,7 @@ export class IndexedDbComponentProvider implements ComponentProvider {
157157
),
158158
platform.newConnectivityMonitor()
159159
);
160-
this.syncEngine = new SyncEngine(
160+
this.syncEngine = new MultiTabSyncEngine(
161161
this.localStore,
162162
this.remoteStore,
163163
this.sharedClientState,
@@ -233,10 +233,7 @@ export class MemoryComponentProvider implements ComponentProvider {
233233
);
234234
}
235235

236-
this.persistence = new MemoryPersistence(
237-
clientId,
238-
this.referenceDelegateFactory
239-
);
236+
this.persistence = new MemoryPersistence(this.referenceDelegateFactory);
240237
this.gcScheduler = null;
241238
this.sharedClientState = new MemorySharedClientState();
242239
this.localStore = new LocalStore(
@@ -268,7 +265,6 @@ export class MemoryComponentProvider implements ComponentProvider {
268265

269266
await this.remoteStore.start();
270267
await this.remoteStore.applyPrimaryState(true);
271-
await this.syncEngine.applyPrimaryState(true);
272268
}
273269

274270
clearPersistence(): never {

0 commit comments

Comments
 (0)