Skip to content

Commit 26db8f5

Browse files
Fix build
1 parent 78588d5 commit 26db8f5

File tree

7 files changed

+45
-30
lines changed

7 files changed

+45
-30
lines changed

packages/firestore/exp/src/api/database.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ import {
3232
MemoryOfflineComponentProvider,
3333
OfflineComponentProvider,
3434
IndexedDbOfflineComponentProvider,
35-
MultiTabOfflineComponentProvider, MultiTabOnlineComponentProvider
35+
MultiTabOfflineComponentProvider,
36+
MultiTabOnlineComponentProvider
3637
} from '../../../src/core/component_provider';
3738

3839
import {
@@ -61,7 +62,7 @@ export class Firestore extends LiteFirestore
6162
private readonly _queue = new AsyncQueue();
6263
private readonly _firestoreClient: FirestoreClient;
6364
private readonly _persistenceKey: string;
64-
private _offlineComponentProvider : OfflineComponentProvider= new MemoryOfflineComponentProvider();
65+
private _offlineComponentProvider: OfflineComponentProvider = new MemoryOfflineComponentProvider();
6566
private _onlineComponentProvider = new OnlineComponentProvider();
6667

6768
// Assigned via _getFirestoreClient()

packages/firestore/index.node.memory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { FirebaseNamespace } from '@firebase/app-types';
2121
import { Firestore } from './src/api/database';
2222
import {
2323
MemoryOfflineComponentProvider,
24-
MemoryOnlineComponentProvider
24+
OnlineComponentProvider
2525
} from './src/core/component_provider';
2626
import { configureForFirebase } from './src/config';
2727
import './register-module';
@@ -40,7 +40,7 @@ export function registerFirestore(instance: FirebaseNamespace): void {
4040
app,
4141
auth,
4242
new MemoryOfflineComponentProvider(),
43-
new MemoryOnlineComponentProvider()
43+
new OnlineComponentProvider()
4444
)
4545
);
4646
instance.registerVersion(name, version, 'node');

packages/firestore/lite/src/api/reference.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,11 @@ export function parent<T>(
526526
if (parentPath.isEmpty()) {
527527
return null;
528528
} else {
529-
return new DocumentReference(child.firestore, /* converter= */ null, parentPath);
529+
return new DocumentReference(
530+
child.firestore,
531+
/* converter= */ null,
532+
parentPath
533+
);
530534
}
531535
} else {
532536
const doc = cast<DocumentReference<T>>(child, DocumentReference);

packages/firestore/src/core/component_provider.ts

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { DatabaseId, DatabaseInfo } from './database_info';
4242
import { Datastore, newDatastore } from '../remote/datastore';
4343
import { User } from '../auth/user';
4444
import { PersistenceSettings } from './firestore_client';
45-
import {debugAssert, debugCast} from '../util/assert';
45+
import { debugAssert, debugCast } from '../util/assert';
4646
import { GarbageCollectionScheduler, Persistence } from '../local/persistence';
4747
import { Code, FirestoreError } from '../util/error';
4848
import { OnlineStateSource } from './types';
@@ -79,7 +79,7 @@ export interface ComponentConfiguration {
7979
}
8080

8181
/**
82-
* Initializes and wires the offline-only components for Firestore.
82+
* Initializes and wires the offline-only components for Firestore.
8383
* Implementations override `initialize()` to provide all components.
8484
*/
8585
export interface OfflineComponentProvider {
@@ -258,7 +258,7 @@ export class MultiTabOfflineComponentProvider extends IndexedDbOfflineComponentP
258258
}
259259

260260
/**
261-
* Initializes and wires the components that are needed to interface with the
261+
* Initializes and wires the components that are needed to interface with the
262262
* network.
263263
*/
264264
export class OnlineComponentProvider {
@@ -345,15 +345,27 @@ export class MultiTabOnlineComponentProvider extends OnlineComponentProvider {
345345
cfg: ComponentConfiguration
346346
): Promise<void> {
347347
await super.initialize(offlineComponentProvider, cfg);
348-
if (cfg.persistenceSettings.durable && cfg.persistenceSettings.synchronizeTabs) {
349-
const sharedClientState = debugCast(offlineComponentProvider.sharedClientState, WebStorageSharedClientState);
350-
const persistence = debugCast(offlineComponentProvider.persistence, IndexedDbPersistence);
348+
if (
349+
cfg.persistenceSettings.durable &&
350+
cfg.persistenceSettings.synchronizeTabs
351+
) {
352+
const sharedClientState = debugCast(
353+
offlineComponentProvider.sharedClientState,
354+
WebStorageSharedClientState
355+
);
356+
const persistence = debugCast(
357+
offlineComponentProvider.persistence,
358+
IndexedDbPersistence
359+
);
351360
const syncEngine = this.syncEngine;
352361

353362
sharedClientState.syncEngine = {
354363
applyBatchState: applyBatchState.bind(null, syncEngine),
355364
applyTargetState: applyTargetState.bind(null, syncEngine),
356-
applyActiveTargetsChange: applyActiveTargetsChange.bind(null, syncEngine),
365+
applyActiveTargetsChange: applyActiveTargetsChange.bind(
366+
null,
367+
syncEngine
368+
),
357369
getActiveClients: getActiveClients.bind(null, syncEngine)
358370
};
359371

@@ -364,21 +376,18 @@ export class MultiTabOnlineComponentProvider extends OnlineComponentProvider {
364376

365377
// NOTE: This will immediately call the listener, so we make sure to
366378
// set it after localStore / remoteStore are started.
367-
await persistence.setPrimaryStateListener(
368-
async isPrimary => {
369-
await applyPrimaryState(syncEngine, isPrimary);
370-
if (offlineComponentProvider.gcScheduler) {
371-
if (isPrimary && !offlineComponentProvider.gcScheduler.started) {
372-
offlineComponentProvider.gcScheduler.start(
373-
offlineComponentProvider.localStore
374-
);
375-
} else if (!isPrimary) {
376-
offlineComponentProvider.gcScheduler.stop();
377-
}
379+
await persistence.setPrimaryStateListener(async isPrimary => {
380+
await applyPrimaryState(syncEngine, isPrimary);
381+
if (offlineComponentProvider.gcScheduler) {
382+
if (isPrimary && !offlineComponentProvider.gcScheduler.started) {
383+
offlineComponentProvider.gcScheduler.start(
384+
offlineComponentProvider.localStore
385+
);
386+
} else if (!isPrimary) {
387+
offlineComponentProvider.gcScheduler.stop();
378388
}
379389
}
380-
);
390+
});
381391
}
382392
}
383393
}
384-

packages/firestore/test/unit/specs/spec_test_components.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import {
1919
ComponentConfiguration,
2020
MemoryOfflineComponentProvider,
2121
OnlineComponentProvider,
22-
MultiTabOfflineComponentProvider, MultiTabOnlineComponentProvider
22+
MultiTabOfflineComponentProvider,
23+
MultiTabOnlineComponentProvider
2324
} from '../../../src/core/component_provider';
2425
import {
2526
GarbageCollectionScheduler,
@@ -154,7 +155,6 @@ export class MockMultiTabOnlineComponentProvider extends MultiTabOnlineComponent
154155
}
155156
}
156157

157-
158158
export class MockMultiTabOfflineComponentProvider extends MultiTabOfflineComponentProvider {
159159
persistence!: MockIndexedDbPersistence;
160160

packages/firestore/test/unit/specs/spec_test_runner.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ import {
127127
SharedWriteTracker,
128128
MockMultiTabOfflineComponentProvider,
129129
MockMemoryOfflineComponentProvider,
130-
MockOnlineComponentProvider, MockMultiTabOnlineComponentProvider
130+
MockOnlineComponentProvider,
131+
MockMultiTabOnlineComponentProvider
131132
} from './spec_test_components';
132133
import { IndexedDbPersistence } from '../../../src/local/indexeddb_persistence';
133134
import { encodeBase64 } from '../../../src/platform/base64';
@@ -295,7 +296,7 @@ abstract class TestRunner {
295296
protected abstract initializeOnlineComponentProvider(
296297
offlineComponentProvider: OfflineComponentProvider,
297298
configuration: ComponentConfiguration
298-
): Promise<MockMultiTabOnlineComponentProvider| MockOnlineComponentProvider>;
299+
): Promise<MockMultiTabOnlineComponentProvider | MockOnlineComponentProvider>;
299300

300301
get isPrimaryClient(): boolean {
301302
return this.syncEngine.isPrimaryClient;

packages/firestore/test/util/api_helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
MultiTabOfflineComponentProvider,
3131
OnlineComponentProvider
3232
} from '../../src/core/component_provider';
33-
import {newQueryForPath, Query as InternalQuery} from '../../src/core/query';
33+
import { newQueryForPath, Query as InternalQuery } from '../../src/core/query';
3434
import {
3535
ChangeType,
3636
DocumentViewChange,

0 commit comments

Comments
 (0)