File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ import { ChromeCacheStore } from '@dvcol/web-extension-utils/chrome/cache';
2
2
3
3
import type { ResponseOrTypedResponse , TypedResponse } from '@dvcol/base-http-client' ;
4
4
import type { CacheStoreEntity } from '@dvcol/common-utils/common' ;
5
+ import type { StorageAreaWrapper } from '@dvcol/web-extension-utils/chrome/storage' ;
6
+
7
+ import { storage } from '~/utils/browser/browser-storage.utils' ;
5
8
6
9
type FlatResponse < T extends Response = ResponseOrTypedResponse > = Record < keyof T , unknown > ;
7
10
@@ -39,6 +42,31 @@ const parseFlatResponse = <T = unknown>(flat: FlatResponse): TypedResponse<T> =>
39
42
} ;
40
43
41
44
export class TraktChromeCacheStore < T > extends ChromeCacheStore < T > {
45
+ constructor ( {
46
+ saveRetention,
47
+ saveAccess,
48
+ evictOnError,
49
+ retention,
50
+ store,
51
+ prefix,
52
+ } : {
53
+ saveRetention ?: boolean ;
54
+ saveAccess ?: boolean ;
55
+ evictOnError ?: boolean ;
56
+ retention ?: number ;
57
+ store ?: StorageAreaWrapper ;
58
+ prefix ?: string ;
59
+ } ) {
60
+ super ( {
61
+ saveRetention,
62
+ saveAccess,
63
+ evictOnError,
64
+ retention,
65
+ store : store ?? storage . local ,
66
+ prefix,
67
+ } ) ;
68
+ }
69
+
42
70
async get ( key : string ) {
43
71
const restored = await this . store . get < CacheStoreEntity < T > > ( `${ this . prefix } :${ key } ` ) ;
44
72
if ( restored ?. type === 'response' ) {
You can’t perform that action at this time.
0 commit comments