@@ -72,9 +72,9 @@ export class Firestore implements FirestoreService {
72
72
73
73
private _settings = new FirestoreSettingsImpl ( { } ) ;
74
74
private _settingsFrozen = false ;
75
- private _emulatorOptions ? : {
75
+ private _emulatorOptions : {
76
76
mockUserToken ?: EmulatorMockTokenOptions | string ;
77
- } ;
77
+ } = { } ;
78
78
79
79
// A task that is assigned when the terminate() is invoked and resolved when
80
80
// all components have shut down. Otherwise, Firestore is not terminated,
@@ -123,7 +123,7 @@ export class Firestore implements FirestoreService {
123
123
) ;
124
124
}
125
125
this . _settings = new FirestoreSettingsImpl ( settings ) ;
126
- this . _emulatorOptions = settings . emulatorOptions ;
126
+ this . _emulatorOptions = settings . emulatorOptions || { } ;
127
127
128
128
if ( settings . credentials !== undefined ) {
129
129
this . _authCredentials = makeAuthCredentialsProvider ( settings . credentials ) ;
@@ -134,15 +134,8 @@ export class Firestore implements FirestoreService {
134
134
return this . _settings ;
135
135
}
136
136
137
- _getPrivateSettings ( ) : PrivateSettings {
138
- const privateSettings : PrivateSettings = {
139
- ...this . _settings ,
140
- emulatorOptions : this . _emulatorOptions
141
- } ;
142
- if ( this . _settings . localCache !== undefined ) {
143
- privateSettings . localCache = this . _settings . localCache ;
144
- }
145
- return privateSettings ;
137
+ _getEmulatorOptions ( ) : { mockUserToken ?: EmulatorMockTokenOptions | string } {
138
+ return this . _emulatorOptions ;
146
139
}
147
140
148
141
_freezeSettings ( ) : FirestoreSettingsImpl {
@@ -332,16 +325,20 @@ export function connectFirestoreEmulator(
332
325
} = { }
333
326
) : void {
334
327
firestore = cast ( firestore , Firestore ) ;
335
- const settings = firestore . _getPrivateSettings ( ) ;
336
- const newHostSetting = `${ host } :${ port } ` ;
328
+ const settings = firestore . _getSettings ( ) ;
329
+ const existingConfig = {
330
+ ...settings ,
331
+ emultorOptions : firestore . _getEmulatorOptions ( )
332
+ } ;
337
333
334
+ const newHostSetting = `${ host } :${ port } ` ;
338
335
if ( settings . host !== DEFAULT_HOST && settings . host !== newHostSetting ) {
339
336
logWarn (
340
337
'Host has been set in both settings() and connectFirestoreEmulator(), emulator host ' +
341
338
'will be used.'
342
339
) ;
343
340
}
344
- const newSettings = {
341
+ const newConfig = {
345
342
...settings ,
346
343
host : newHostSetting ,
347
344
ssl : false ,
@@ -350,13 +347,13 @@ export function connectFirestoreEmulator(
350
347
351
348
// No-op if the new configuration matches the current configuration. This supports SSR
352
349
// enviornments which might call `connectFirestoreEmulator` multiple times as a standard practice.
353
- if ( deepEqual ( newSettings , settings ) ) {
350
+ if ( deepEqual ( newConfig , existingConfig ) ) {
354
351
console . error ( 'DEDB settings are the same!' ) ;
355
352
return ;
356
353
}
357
354
console . error ( 'DEDB settings differ!' ) ;
358
355
359
- firestore . _setSettings ( newSettings ) ;
356
+ firestore . _setSettings ( newConfig ) ;
360
357
361
358
if ( options . mockUserToken ) {
362
359
let token : string ;
0 commit comments