Skip to content

Commit 991010c

Browse files
committed
Use deepEqual()
1 parent 28de7ca commit 991010c

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

packages/firestore/src/exp/database.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
} from '@firebase/app-exp';
2525
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
2626
import { Provider } from '@firebase/component';
27+
import { deepEqual } from '../../../util/dist';
2728

2829
import {
2930
IndexedDbOfflineComponentProvider,
@@ -129,23 +130,8 @@ export function initializeFirestore(
129130

130131
if (provider.isInitialized()) {
131132
const existingInstance = provider.getImmediate();
132-
const initialOptions = provider.getOptions() as FirestoreSettings;
133-
// Every option can currently be compared shallowly.
134-
// We could currently do a deepEqual() on `settings` but if we add
135-
// a new option to `FirestoreSettings` that needs a custom
136-
// comparison, it should be coded separately. This makes it less
137-
// likely to be missed.
138-
const shallowOptionsKeys: Array<keyof FirestoreSettings> = [
139-
'cacheSizeBytes',
140-
'experimentalAutoDetectLongPolling',
141-
'experimentalForceLongPolling',
142-
'host',
143-
'ignoreUndefinedProperties',
144-
'ssl'
145-
];
146-
if (
147-
shallowOptionsKeys.every(key => initialOptions[key] === settings[key])
148-
) {
133+
const initialSettings = provider.getOptions() as FirestoreSettings;
134+
if (deepEqual(initialSettings, settings)) {
149135
return existingInstance;
150136
} else {
151137
throw new FirestoreError(

0 commit comments

Comments
 (0)