@@ -29,16 +29,20 @@ const OBJECT_STORE_NAME = 'firebase-messaging-store';
29
29
let dbPromise : Promise < DBWrapper > | null = null ;
30
30
function getDbPromise ( ) : Promise < DBWrapper > {
31
31
if ( ! dbPromise ) {
32
- dbPromise = openDB ( DATABASE_NAME , DATABASE_VERSION , ( upgradeDb , oldVersion ) => {
33
- // We don't use 'break' in this switch statement, the fall-through behavior is what we want,
34
- // because if there are multiple versions between the old version and the current version, we
35
- // want ALL the migrations that correspond to those versions to run, not only the last one.
36
- // eslint-disable-next-line default-case
37
- switch ( oldVersion ) {
38
- case 0 :
39
- upgradeDb . createObjectStore ( OBJECT_STORE_NAME ) ;
32
+ dbPromise = openDB (
33
+ DATABASE_NAME ,
34
+ DATABASE_VERSION ,
35
+ ( upgradeDb , oldVersion ) => {
36
+ // We don't use 'break' in this switch statement, the fall-through behavior is what we want,
37
+ // because if there are multiple versions between the old version and the current version, we
38
+ // want ALL the migrations that correspond to those versions to run, not only the last one.
39
+ // eslint-disable-next-line default-case
40
+ switch ( oldVersion ) {
41
+ case 0 :
42
+ upgradeDb . createObjectStore ( OBJECT_STORE_NAME ) ;
43
+ }
40
44
}
41
- } ) ;
45
+ ) ;
42
46
}
43
47
return dbPromise ;
44
48
}
@@ -49,10 +53,10 @@ export async function dbGet(
49
53
) : Promise < TokenDetails | undefined > {
50
54
const key = getKey ( firebaseDependencies ) ;
51
55
const db = await getDbPromise ( ) ;
52
- const tokenDetails = await db
56
+ const tokenDetails = ( await db
53
57
. transaction ( OBJECT_STORE_NAME )
54
58
. objectStore ( OBJECT_STORE_NAME )
55
- . get ( key ) as TokenDetails ;
59
+ . get ( key ) ) as TokenDetails ;
56
60
57
61
if ( tokenDetails ) {
58
62
return tokenDetails ;
0 commit comments