Page MenuHomePhabricator

D7667.id25853.diff
No OneTemporary

D7667.id25853.diff

diff --git a/web/redux/comm-redux-storage-engine.js b/web/redux/comm-redux-storage-engine.js
--- a/web/redux/comm-redux-storage-engine.js
+++ b/web/redux/comm-redux-storage-engine.js
@@ -1,10 +1,17 @@
// @flow
+import storage from 'redux-persist/es/storage/index.js';
+
import { databaseModule } from '../database/database-module-provider.js';
import { workerRequestMessageTypes } from '../types/worker-types.js';
const commReduxStorageEngine = {
getItem: async (key: string): Promise<string> => {
+ const isSupported = await databaseModule.isDatabaseSupported();
+ if (!isSupported) {
+ return await storage.getItem(key);
+ }
+
const result = await databaseModule.schedule({
type: workerRequestMessageTypes.GET_PERSIST_STORAGE_ITEM,
key,
@@ -15,6 +22,12 @@
return result.item;
},
setItem: async (key: string, item: string): Promise<void> => {
+ const isSupported = await databaseModule.isDatabaseSupported();
+ if (!isSupported) {
+ await storage.setItem(key, item);
+ return;
+ }
+
await databaseModule.schedule({
type: workerRequestMessageTypes.SET_PERSIST_STORAGE_ITEM,
key,
@@ -22,6 +35,12 @@
});
},
removeItem: async (key: string): Promise<void> => {
+ const isSupported = await databaseModule.isDatabaseSupported();
+ if (!isSupported) {
+ await storage.removeItem(key);
+ return;
+ }
+
await databaseModule.schedule({
type: workerRequestMessageTypes.REMOVE_PERSIST_STORAGE_ITEM,
key,

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 11:37 PM (19 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2592099
Default Alt Text
D7667.id25853.diff (1 KB)

Event Timeline