@@ -29,8 +29,7 @@ import {
29
29
} from './encoded_resource_path' ;
30
30
import {
31
31
IndexedDbLruDelegate ,
32
- IndexedDbPersistence ,
33
- IndexedDbTransaction
32
+ IndexedDbPersistence
34
33
} from './indexeddb_persistence' ;
35
34
import {
36
35
DbTarget ,
@@ -46,7 +45,7 @@ import { PersistenceTransaction } from './persistence';
46
45
import { PersistencePromise } from './persistence_promise' ;
47
46
import { TargetCache } from './target_cache' ;
48
47
import { TargetData } from './target_data' ;
49
- import { SimpleDb , SimpleDbStore , SimpleDbTransaction } from './simple_db' ;
48
+ import { SimpleDbStore } from './simple_db' ;
50
49
import { Target } from '../core/target' ;
51
50
52
51
export class IndexedDbTargetCache implements TargetCache {
@@ -90,8 +89,8 @@ export class IndexedDbTargetCache implements TargetCache {
90
89
getHighestSequenceNumber (
91
90
transaction : PersistenceTransaction
92
91
) : PersistencePromise < ListenSequenceNumber > {
93
- return getHighestListenSequenceNumber (
94
- ( transaction as IndexedDbTransaction ) . simpleDbTransaction
92
+ return this . retrieveMetadata ( transaction ) . next (
93
+ targetGlobal => targetGlobal . highestListenSequenceNumber
95
94
) ;
96
95
}
97
96
@@ -192,9 +191,12 @@ export class IndexedDbTargetCache implements TargetCache {
192
191
private retrieveMetadata (
193
192
transaction : PersistenceTransaction
194
193
) : PersistencePromise < DbTargetGlobal > {
195
- return retrieveMetadata (
196
- ( transaction as IndexedDbTransaction ) . simpleDbTransaction
197
- ) ;
194
+ return globalTargetStore ( transaction )
195
+ . get ( DbTargetGlobal . key )
196
+ . next ( metadata => {
197
+ hardAssert ( metadata !== null , 'Missing metadata row.' ) ;
198
+ return metadata ;
199
+ } ) ;
198
200
}
199
201
200
202
private saveMetadata (
@@ -422,27 +424,6 @@ function globalTargetStore(
422
424
) ;
423
425
}
424
426
425
- function retrieveMetadata (
426
- txn : SimpleDbTransaction
427
- ) : PersistencePromise < DbTargetGlobal > {
428
- const globalStore = SimpleDb . getStore < DbTargetGlobalKey , DbTargetGlobal > (
429
- txn ,
430
- DbTargetGlobal . store
431
- ) ;
432
- return globalStore . get ( DbTargetGlobal . key ) . next ( metadata => {
433
- hardAssert ( metadata !== null , 'Missing metadata row.' ) ;
434
- return metadata ;
435
- } ) ;
436
- }
437
-
438
- export function getHighestListenSequenceNumber (
439
- txn : SimpleDbTransaction
440
- ) : PersistencePromise < ListenSequenceNumber > {
441
- return retrieveMetadata ( txn ) . next (
442
- targetGlobal => targetGlobal . highestListenSequenceNumber
443
- ) ;
444
- }
445
-
446
427
/**
447
428
* Helper to get a typed SimpleDbStore for the document target object store.
448
429
*/
0 commit comments