diff --git a/web/redux/comm-redux-storage-engine.js b/web/redux/comm-redux-storage-engine.js index e159e6ef7..bfbba011c 100644 --- a/web/redux/comm-redux-storage-engine.js +++ b/web/redux/comm-redux-storage-engine.js @@ -1,54 +1,54 @@ // @flow import storage from 'redux-persist/es/storage/index.js'; import { getDatabaseModule } from '../database/database-module-provider.js'; import { workerRequestMessageTypes } from '../types/worker-types.js'; const commReduxStorageEngine = { getItem: async (key: string): Promise => { const databaseModule = await getDatabaseModule(); const isSupported = await databaseModule.isDatabaseSupported(); if (!isSupported) { return await storage.getItem(key); } const result = await databaseModule.schedule({ type: workerRequestMessageTypes.GET_PERSIST_STORAGE_ITEM, key, }); - if (typeof result?.item !== 'string') { + if (!result || typeof result.item !== 'string') { throw new Error('Wrong type returned for storage item'); } return result.item; }, setItem: async (key: string, item: string): Promise => { const databaseModule = await getDatabaseModule(); const isSupported = await databaseModule.isDatabaseSupported(); if (!isSupported) { await storage.setItem(key, item); return; } await databaseModule.schedule({ type: workerRequestMessageTypes.SET_PERSIST_STORAGE_ITEM, key, item, }); }, removeItem: async (key: string): Promise => { const databaseModule = await getDatabaseModule(); const isSupported = await databaseModule.isDatabaseSupported(); if (!isSupported) { await storage.removeItem(key); return; } await databaseModule.schedule({ type: workerRequestMessageTypes.REMOVE_PERSIST_STORAGE_ITEM, key, }); }, }; export default commReduxStorageEngine;