@@ -41,11 +41,17 @@ import {
41
41
setComponentProviders
42
42
} from './components' ;
43
43
import {
44
+ ComponentConfiguration ,
44
45
IndexedDbOfflineComponentProvider ,
45
46
MultiTabOfflineComponentProvider ,
46
47
MultiTabOnlineComponentProvider ,
47
48
OnlineComponentProvider
48
49
} from '../../../src/core/component_provider' ;
50
+ import { MAX_CONCURRENT_LIMBO_RESOLUTIONS } from '../../../src/core/firestore_client' ;
51
+ import { DatabaseInfo } from '../../../src/core/database_info' ;
52
+ import { DEFAULT_HOST , DEFAULT_SSL } from '../../../lite/src/api/components' ;
53
+ import { User } from '../../../src/auth/user' ;
54
+ import { AutoId } from '../../../src/util/misc' ;
49
55
50
56
/**
51
57
* The root reference to the Firestore database and the entry point for the
@@ -55,6 +61,10 @@ export class Firestore extends LiteFirestore
55
61
implements firestore . FirebaseFirestore , _FirebaseService {
56
62
readonly _queue = new AsyncQueue ( ) ;
57
63
readonly _persistenceKey : string ;
64
+ // TODO(firestoreexp): Support user change without SyncEning
65
+ private _initialUser : User = User . UNAUTHENTICATED ;
66
+
67
+ private readonly _clientId = AutoId . newId ( ) ;
58
68
59
69
// We override the Settings property of the Lite SDK since the full Firestore
60
70
// SDK supports more settings.
@@ -66,6 +76,34 @@ export class Firestore extends LiteFirestore
66
76
) {
67
77
super ( app , authProvider ) ;
68
78
this . _persistenceKey = app . name ;
79
+
80
+ this . _credentials . getToken ( ) . then ( token => {
81
+ if ( token ) {
82
+ this . _initialUser = token . user ;
83
+ }
84
+ } ) ;
85
+ }
86
+
87
+ _getDatabaseInfo ( ) : DatabaseInfo {
88
+ const settings = this . _getSettings ( ) ;
89
+ return new DatabaseInfo (
90
+ this . _databaseId ,
91
+ this . _persistenceKey ,
92
+ settings . host ?? DEFAULT_HOST ,
93
+ settings . ssl ?? DEFAULT_SSL ,
94
+ /** forceLongPolling= */ false
95
+ ) ;
96
+ }
97
+ _getConfiguration ( ) : ComponentConfiguration {
98
+ return {
99
+ asyncQueue : this . _queue ,
100
+ databaseInfo : this . _getDatabaseInfo ( ) ,
101
+ clientId : this . _clientId ,
102
+ credentials : this . _credentials ,
103
+ initialUser : this . _initialUser ,
104
+ maxConcurrentLimboResolutions : MAX_CONCURRENT_LIMBO_RESOLUTIONS ,
105
+ persistenceSettings : { durable : false }
106
+ } ;
69
107
}
70
108
71
109
_getSettings ( ) : firestore . Settings {
0 commit comments