Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3376232
D7660.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
D7660.diff
View Options
diff --git a/web/root.js b/web/root.js
--- a/web/root.js
+++ b/web/root.js
@@ -14,7 +14,9 @@
import { isDev } from 'lib/utils/dev-utils.js';
import App from './app.react.js';
+import { databaseModule } from './database/database-module-provider.js';
import { SQLiteDataHandler } from './database/sqlite-data-handler.js';
+import { isSQLiteSupported } from './database/utils/db-utils.js';
import ErrorBoundary from './error-boundary.react.js';
import Loading from './loading.react.js';
import { createAsyncMigrate } from './redux/create-async-migrate.js';
@@ -22,6 +24,7 @@
import type { AppState, Action } from './redux/redux-setup.js';
import history from './router-history.js';
import Socket from './socket.react.js';
+import { workerRequestMessageTypes } from './types/worker-types.js';
const migrations = {
[1]: async state => {
@@ -39,6 +42,32 @@
},
};
},
+ [2]: async state => {
+ const currentLoggedInUserID = preloadedState.currentUserInfo?.anonymous
+ ? undefined
+ : preloadedState.currentUserInfo?.id;
+ const isSupported = isSQLiteSupported(currentLoggedInUserID);
+ if (!isSupported) {
+ return state;
+ }
+
+ const { drafts } = state.draftStore;
+ const draftStoreOperations = [];
+ for (const key in drafts) {
+ const text = drafts[key];
+ draftStoreOperations.push({
+ type: 'update',
+ payload: { key, text },
+ });
+ }
+
+ await databaseModule.schedule({
+ type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS,
+ storeOperations: { draftStoreOperations },
+ });
+
+ return state;
+ },
};
const persistConfig = {
key: 'root',
@@ -52,7 +81,7 @@
'commServicesAccessToken',
],
migrate: (createAsyncMigrate(migrations, { debug: isDev }): any),
- version: 1,
+ version: 2,
};
declare var preloadedState: AppState;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 10:51 PM (21 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2591978
Default Alt Text
D7660.diff (1 KB)
Attached To
Mode
D7660: [web-db] migrate drafts to SQLite
Attached
Detach File
Event Timeline
Log In to Comment