@@ -45,7 +45,11 @@ import { Code, FirestoreError } from '../../../src/util/error';
45
45
import { Deferred } from '../../../src/util/promise' ;
46
46
import { LruParams } from '../../../src/local/lru_garbage_collector' ;
47
47
import { CACHE_SIZE_UNLIMITED } from '../../../src/api/database' ;
48
- import { DatabaseInfo } from '../../../src/core/database_info' ;
48
+ import { DatabaseId , DatabaseInfo } from '../../../src/core/database_info' ;
49
+ import {
50
+ indexedDbStoragePrefix ,
51
+ indexedDbClearPersistence
52
+ } from '../../../src/local/indexeddb_persistence' ;
49
53
50
54
/**
51
55
* The root reference to the Firestore database and the entry point for the
@@ -143,7 +147,16 @@ export class Firestore extends LiteFirestore
143
147
return terminate ( this ) ;
144
148
}
145
149
146
- _clearPersistence ( ) : Promise < void > {
150
+ /**
151
+ * Verifies that the client is not running and clears persistence by invoking
152
+ * `delegate` on the async queue.
153
+ *
154
+ * @param delegate A function that clears the clients
155
+ * backing storage.
156
+ */
157
+ _clearPersistence (
158
+ delegate : ( databaseId : DatabaseId , persistenceKey : string ) => Promise < void >
159
+ ) : Promise < void > {
147
160
if ( this . _deferredInitialization !== undefined && ! this . _terminated ) {
148
161
throw new FirestoreError (
149
162
Code . FAILED_PRECONDITION ,
@@ -152,16 +165,10 @@ export class Firestore extends LiteFirestore
152
165
) ;
153
166
}
154
167
155
- const settings = this . _getSettings ( ) ;
156
168
const deferred = new Deferred < void > ( ) ;
157
169
this . _queue . enqueueAndForgetEvenAfterShutdown ( async ( ) => {
158
170
try {
159
- const databaseInfo = this . _makeDatabaseInfo (
160
- settings . host ,
161
- settings . ssl ,
162
- settings . experimentalForceLongPolling
163
- ) ;
164
- await this . _componentProvider . clearPersistence ( databaseInfo ) ;
171
+ await delegate ( this . _databaseId , this . _persistenceKey ) ;
165
172
deferred . resolve ( ) ;
166
173
} catch ( e ) {
167
174
deferred . reject ( e ) ;
@@ -247,7 +254,11 @@ export function clearIndexedDbPersistence(
247
254
firestore : firestore . FirebaseFirestore
248
255
) : Promise < void > {
249
256
const firestoreImpl = cast ( firestore , Firestore ) ;
250
- return firestoreImpl . _clearPersistence ( ) ;
257
+ return firestoreImpl . _clearPersistence ( ( databaseId , persistenceKey ) => {
258
+ return indexedDbClearPersistence (
259
+ indexedDbStoragePrefix ( databaseId , persistenceKey )
260
+ ) ;
261
+ } ) ;
251
262
}
252
263
253
264
export function waitForPendingWrites (
0 commit comments