Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3361201
D7421.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D7421.diff
View Options
diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js
--- a/native/redux/redux-setup.js
+++ b/native/redux/redux-setup.js
@@ -29,9 +29,7 @@
import type { ThreadStoreOperation } from 'lib/types/thread-types.js';
import { reduxLoggerMiddleware } from 'lib/utils/action-logger.js';
import { setNewSessionActionType } from 'lib/utils/action-utils.js';
-import { convertMessageStoreOperationsToClientDBOperations } from 'lib/utils/message-ops-utils.js';
import { defaultNotifPermissionAlertInfo } from 'lib/utils/push-alerts.js';
-import { convertThreadStoreOperationsToClientDBOperations } from 'lib/utils/thread-ops-utils.js';
import {
resetUserStateActionType,
@@ -49,8 +47,8 @@
import { remoteReduxDevServerConfig } from './dev-tools.js';
import { defaultDimensionsInfo } from './dimensions-updater.react.js';
import { persistConfig, setPersistor } from './persist.js';
+import { processDBStoreOperations } from './redux-utils.js';
import type { AppState } from './state-types.js';
-import { commCoreModule } from '../native-modules.js';
import { defaultNavInfo } from '../navigation/default-state.js';
import { getGlobalNavContext } from '../navigation/icky-global.js';
import { activeMessageListSelector } from '../navigation/nav-selectors.js';
@@ -58,7 +56,6 @@
import { defaultDeviceCameraInfo } from '../types/camera.js';
import { defaultConnectivityInfo } from '../types/connectivity.js';
import { defaultGlobalThemeInfo } from '../types/themes.js';
-import { isTaskCancelledError } from '../utils/error-handling.js';
import { isStaffRelease } from '../utils/staff-utils.js';
import {
defaultURLPrefix,
@@ -341,45 +338,11 @@
...fixUnreadActiveThreadResult.threadStoreOperations,
];
- const convertedThreadStoreOperations =
- convertThreadStoreOperationsToClientDBOperations(
- threadStoreOperationsWithUnreadFix,
- );
- const convertedMessageStoreOperations =
- convertMessageStoreOperationsToClientDBOperations(messageStoreOperations);
- (async () => {
- try {
- const promises = [];
- if (convertedThreadStoreOperations.length > 0) {
- promises.push(
- commCoreModule.processThreadStoreOperations(
- convertedThreadStoreOperations,
- ),
- );
- }
- if (convertedMessageStoreOperations.length > 0) {
- promises.push(
- commCoreModule.processMessageStoreOperations(
- convertedMessageStoreOperations,
- ),
- );
- }
- if (draftStoreOperations.length > 0) {
- promises.push(
- commCoreModule.processDraftStoreOperations(draftStoreOperations),
- );
- }
- await Promise.all(promises);
- } catch (e) {
- if (isTaskCancelledError(e)) {
- return;
- }
- // this code will make an entry in SecureStore and cause re-creating
- // database when user will open app again
- commCoreModule.reportDBOperationsFailure();
- commCoreModule.terminate();
- }
- })();
+ processDBStoreOperations({
+ draftStoreOperations,
+ messageStoreOperations,
+ threadStoreOperations: threadStoreOperationsWithUnreadFix,
+ });
return state;
}
diff --git a/native/redux/redux-utils.js b/native/redux/redux-utils.js
--- a/native/redux/redux-utils.js
+++ b/native/redux/redux-utils.js
@@ -2,7 +2,13 @@
import { useSelector as reactReduxUseSelector } from 'react-redux';
+import type { StoreOperations } from 'lib/types/store-ops-types.js';
+import { convertMessageStoreOperationsToClientDBOperations } from 'lib/utils/message-ops-utils.js';
+import { convertThreadStoreOperationsToClientDBOperations } from 'lib/utils/thread-ops-utils.js';
+
import type { AppState } from './state-types.js';
+import { commCoreModule } from '../native-modules.js';
+import { isTaskCancelledError } from '../utils/error-handling.js';
function useSelector<SS>(
selector: (state: AppState) => SS,
@@ -11,4 +17,51 @@
return reactReduxUseSelector(selector, equalityFn);
}
-export { useSelector };
+async function processDBStoreOperations(
+ storeOperations: StoreOperations,
+): Promise<void> {
+ const {
+ draftStoreOperations,
+ threadStoreOperations,
+ messageStoreOperations,
+ } = storeOperations;
+
+ const convertedThreadStoreOperations =
+ convertThreadStoreOperationsToClientDBOperations(threadStoreOperations);
+ const convertedMessageStoreOperations =
+ convertMessageStoreOperationsToClientDBOperations(messageStoreOperations);
+
+ try {
+ const promises = [];
+ if (convertedThreadStoreOperations.length > 0) {
+ promises.push(
+ commCoreModule.processThreadStoreOperations(
+ convertedThreadStoreOperations,
+ ),
+ );
+ }
+ if (convertedMessageStoreOperations.length > 0) {
+ promises.push(
+ commCoreModule.processMessageStoreOperations(
+ convertedMessageStoreOperations,
+ ),
+ );
+ }
+ if (draftStoreOperations.length > 0) {
+ promises.push(
+ commCoreModule.processDraftStoreOperations(draftStoreOperations),
+ );
+ }
+ await Promise.all(promises);
+ } catch (e) {
+ if (isTaskCancelledError(e)) {
+ return;
+ }
+ // this code will make an entry in SecureStore and cause re-creating
+ // database when user will open app again
+ commCoreModule.reportDBOperationsFailure();
+ commCoreModule.terminate();
+ }
+}
+
+export { useSelector, processDBStoreOperations };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 3:44 PM (21 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2580353
Default Alt Text
D7421.diff (5 KB)
Attached To
Mode
D7421: [native] extract processing store operations to separate function
Attached
Detach File
Event Timeline
Log In to Comment