diff --git a/src/web/lib/storage.ts b/src/web/lib/storage.ts index c9e0308..24ac9a7 100644 --- a/src/web/lib/storage.ts +++ b/src/web/lib/storage.ts @@ -1,12 +1,23 @@ -import localforage from 'localforage'; +import LocalForage from 'localforage'; +type LocalForageOptions = Parameters[0]; -const storage = localforage.createInstance({ - driver: localforage.LOCALSTORAGE, +const defaultOptions: LocalForageOptions = { + driver: LocalForage.LOCALSTORAGE, name: 'inspirat', version: 1, description: 'Inspirat' -}); +}; +const storage = LocalForage.createInstance(defaultOptions); + +const originalCreateInstance = storage.createInstance.bind(storage); + +storage.createInstance = (options: LocalForageOptions) => { + return Reflect.apply(originalCreateInstance, storage, [{ + ...defaultOptions, + ...options + }]); +}; export default storage;