Skip to content

Commit 4058d93

Browse files
committed
WIP
1 parent 78c71fc commit 4058d93

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/data-connect/src/cache/Cache.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,13 @@ export class DataConnectCache {
7272
private connectorConfig: ConnectorConfig,
7373
private host: string,
7474
private cacheSettings?: CacheSettings
75-
) {}
75+
) {
76+
}
7677

7778
async initialize(): Promise<void> {
7879
if (!this.cacheProvider) {
80+
const identifier = await this.getIdentifier(this.uid);
81+
this.cacheProvider = this.initializeNewProviders(identifier);
7982
}
8083
}
8184

@@ -93,15 +96,15 @@ export class DataConnectCache {
9396

9497
setAuthProvider(_authTokenProvider: AuthTokenProvider): void {
9598
this.authProvider.addTokenChangeListener(async _ => {
99+
await this.cacheProvider?.close();
96100
this.uid = this.authProvider.getAuth().getUid();
97-
this.cacheProvider = await this.initializeNewProviders();
101+
const identifier = await this.getIdentifier(this.uid);
102+
this.cacheProvider = this.initializeNewProviders(identifier);
98103
});
99104
}
100105

101-
async initializeNewProviders(): Promise<CacheProvider> {
102-
await this.cacheProvider?.close();
106+
initializeNewProviders(identifier: string): CacheProvider {
103107
let cacheProvider: CacheProvider;
104-
const identifier = await this.getIdentifier(this.uid);
105108
const isPersistenceEnabled =
106109
this.cacheSettings?.storage instanceof PublicIndexedDbProvider;
107110
if (this.cacheSettings) {

0 commit comments

Comments
 (0)