Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3376374
D7667.id25853.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D7667.id25853.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D7667: [web-db] choose storage engine depending on whether database is supported or not
Attached
Detach File
Event Timeline
Log In to Comment