Page MenuHomePhabricator

D9955.id33515.diff
No OneTemporary

D9955.id33515.diff

diff --git a/web/database/utils/store.js b/web/database/utils/store.js
--- a/web/database/utils/store.js
+++ b/web/database/utils/store.js
@@ -2,7 +2,10 @@
import { reportStoreOpsHandlers } from 'lib/ops/report-store-ops.js';
import { threadStoreOpsHandlers } from 'lib/ops/thread-store-ops.js';
-import type { ClientStore } from 'lib/types/store-ops-types.js';
+import type {
+ ClientStore,
+ StoreOperations,
+} from 'lib/types/store-ops-types.js';
import { workerRequestMessageTypes } from '../../types/worker-types.js';
import { getDatabaseModule } from '../database-module-provider.js';
@@ -46,4 +49,30 @@
return result;
}
-export { getClientStore };
+async function processDBStoreOperations(
+ storeOperations: StoreOperations,
+): Promise<void> {
+ const { draftStoreOperations, threadStoreOperations, reportStoreOperations } =
+ storeOperations;
+
+ const convertedThreadStoreOperations =
+ threadStoreOpsHandlers.convertOpsToClientDBOps(threadStoreOperations);
+ const convertedReportStoreOperations =
+ reportStoreOpsHandlers.convertOpsToClientDBOps(reportStoreOperations);
+
+ const databaseModule = await getDatabaseModule();
+ const isSupported = await databaseModule.isDatabaseSupported();
+ if (!isSupported) {
+ return;
+ }
+ await databaseModule.schedule({
+ type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS,
+ storeOperations: {
+ draftStoreOperations,
+ reportStoreOperations: convertedReportStoreOperations,
+ threadStoreOperations: convertedThreadStoreOperations,
+ },
+ });
+}
+
+export { getClientStore, processDBStoreOperations };
diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js
--- a/web/redux/redux-setup.js
+++ b/web/redux/redux-setup.js
@@ -7,8 +7,6 @@
logOutActionTypes,
deleteAccountActionTypes,
} from 'lib/actions/user-actions.js';
-import { reportStoreOpsHandlers } from 'lib/ops/report-store-ops.js';
-import { threadStoreOpsHandlers } from 'lib/ops/thread-store-ops.js';
import baseReducer from 'lib/reducers/master-reducer.js';
import { mostRecentlyReadThreadSelector } from 'lib/selectors/thread-selectors.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
@@ -58,11 +56,10 @@
import reduceNavInfo from './nav-reducer.js';
import { onStateDifference } from './redux-debug-utils.js';
import { getVisibility } from './visibility.js';
-import { getDatabaseModule } from '../database/database-module-provider.js';
+import { processDBStoreOperations } from '../database/utils/store.js';
import { activeThreadSelector } from '../selectors/nav-selectors.js';
import { type NavInfo } from '../types/nav-types.js';
import type { InitialReduxState } from '../types/redux-types.js';
-import { workerRequestMessageTypes } from '../types/worker-types.js';
export type WindowDimensions = { width: number, height: number };
@@ -210,38 +207,7 @@
const baseReducerResult = baseReducer(state, action, onStateDifference);
state = baseReducerResult.state;
- const {
- storeOperations: {
- draftStoreOperations,
- reportStoreOperations,
- threadStoreOperations,
- },
- } = baseReducerResult;
- if (
- draftStoreOperations.length > 0 ||
- reportStoreOperations.length > 0 ||
- threadStoreOperations.length > 0
- ) {
- (async () => {
- const databaseModule = await getDatabaseModule();
- const isSupported = await databaseModule.isDatabaseSupported();
- if (!isSupported) {
- return;
- }
- const convertedReportStoreOperations =
- reportStoreOpsHandlers.convertOpsToClientDBOps(reportStoreOperations);
- const convertedThreadStoreOperations =
- threadStoreOpsHandlers.convertOpsToClientDBOps(threadStoreOperations);
- await databaseModule.schedule({
- type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS,
- storeOperations: {
- draftStoreOperations,
- reportStoreOperations: convertedReportStoreOperations,
- threadStoreOperations: convertedThreadStoreOperations,
- },
- });
- })();
- }
+ processDBStoreOperations(baseReducerResult.storeOperations);
}
const communityPickerStore = reduceCommunityPickerStore(

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 7:49 AM (18 h, 46 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2574619
Default Alt Text
D9955.id33515.diff (4 KB)

Event Timeline