This repository was archived by the owner on Jan 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-8
lines changed Expand file tree Collapse file tree 1 file changed +21
-8
lines changed Original file line number Diff line number Diff line change 1
1
import * as localForage from 'localforage'
2
2
import UniversalStorage from '@vue-storefront/core/store/lib/storage'
3
3
import { currentStoreView } from '@vue-storefront/store/lib/multistore'
4
- // use it to initialize cache storage in modules
5
- export function initCacheStorage ( key ) {
4
+ import rootStore from '@vue-storefront/store'
5
+
6
+
7
+ export function initCacheStorage ( key , localised = true ) {
6
8
const storeView = currentStoreView ( )
7
9
const dbNamePrefix = storeView . storeCode ? storeView . storeCode + '-' : ''
10
+ const config = rootStore . state . config
11
+ const cacheDriver = config . localForage && config . localForage . defaultDrivers [ 'orders' ] || 'LOCALSTORAGE'
8
12
9
- const cacheStorage = new UniversalStorage ( localForage . createInstance ( {
10
- name : dbNamePrefix + 'shop' ,
11
- storeName : key
12
- } ) )
13
-
14
- return cacheStorage
13
+ if ( localised ) {
14
+ const cacheStorage = new UniversalStorage ( localForage . createInstance ( {
15
+ name : dbNamePrefix + 'shop' ,
16
+ storeName : key ,
17
+ driver : localForage [ cacheDriver ]
18
+ } ) )
19
+ return cacheStorage
20
+ } else {
21
+ const cacheStorage = new UniversalStorage ( localForage . createInstance ( {
22
+ name : 'shop' ,
23
+ storeName : key ,
24
+ driver : localForage [ cacheDriver ]
25
+ } ) )
26
+ return cacheStorage
27
+ }
15
28
}
You can’t perform that action at this time.
0 commit comments