Page MenuHomePhabricator

D11563.id38871.diff
No OneTemporary

D11563.id38871.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,17 +1,11 @@
// @flow
-import storage from 'redux-persist/es/storage/index.js';
-
import { getCommSharedWorker } from '../shared-worker/shared-worker-provider.js';
import { workerRequestMessageTypes } from '../types/worker-types.js';
const commReduxStorageEngine = {
getItem: async (key: string): Promise<string> => {
const sharedWorker = await getCommSharedWorker();
- const isSupported = await sharedWorker.isSupported();
- if (!isSupported) {
- return await storage.getItem(key);
- }
const result = await sharedWorker.schedule({
type: workerRequestMessageTypes.GET_PERSIST_STORAGE_ITEM,
@@ -24,11 +18,6 @@
},
setItem: async (key: string, item: string): Promise<void> => {
const sharedWorker = await getCommSharedWorker();
- const isSupported = await sharedWorker.isSupported();
- if (!isSupported) {
- await storage.setItem(key, item);
- return;
- }
await sharedWorker.schedule({
type: workerRequestMessageTypes.SET_PERSIST_STORAGE_ITEM,
@@ -38,11 +27,6 @@
},
removeItem: async (key: string): Promise<void> => {
const sharedWorker = await getCommSharedWorker();
- const isSupported = await sharedWorker.isSupported();
- if (!isSupported) {
- await storage.removeItem(key);
- return;
- }
await sharedWorker.schedule({
type: workerRequestMessageTypes.REMOVE_PERSIST_STORAGE_ITEM,
diff --git a/web/shared-worker/shared-worker-provider.js b/web/shared-worker/shared-worker-provider.js
--- a/web/shared-worker/shared-worker-provider.js
+++ b/web/shared-worker/shared-worker-provider.js
@@ -37,14 +37,14 @@
| { +type: 'NOT_RUNNING' | 'INIT_SUCCESS' | 'INIT_ERROR' }
| { +type: 'INIT_IN_PROGRESS', +initPromise: Promise<void> };
-type InitOptions = { +clearDatabase: boolean };
+type InitOptions = { +clearDatabase: boolean, +markAsCorrupted?: boolean };
class CommSharedWorker {
worker: ?SharedWorker;
workerProxy: ?WorkerConnectionProxy;
status: SharedWorkerStatus = { type: sharedWorkerStatuses.notRunning };
- async init({ clearDatabase }: InitOptions): Promise<void> {
+ async init({ clearDatabase, markAsCorrupted }: InitOptions): Promise<void> {
if (!isSQLiteSupported()) {
console.warn('SQLite is not supported');
this.status = { type: sharedWorkerStatuses.initError };
@@ -89,6 +89,11 @@
const origin = window.location.origin;
+ if (markAsCorrupted) {
+ this.status = { type: sharedWorkerStatuses.initError };
+ return;
+ }
+
try {
let encryptionKey = null;
if (isDesktopSafari) {
diff --git a/web/shared-worker/utils/store.js b/web/shared-worker/utils/store.js
--- a/web/shared-worker/utils/store.js
+++ b/web/shared-worker/utils/store.js
@@ -214,7 +214,7 @@
ops.length > 0,
)
) {
- await sharedWorker.init({ clearDatabase: true });
+ await sharedWorker.init({ clearDatabase: true, markAsCorrupted: true });
location.reload();
}
}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 4:08 PM (16 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2682028
Default Alt Text
D11563.id38871.diff (3 KB)

Event Timeline