Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3366002
D11886.id39908.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D11886.id39908.diff
View Options
diff --git a/native/redux/handle-redux-migration-failure.js b/native/redux/handle-redux-migration-failure.js
new file mode 100644
--- /dev/null
+++ b/native/redux/handle-redux-migration-failure.js
@@ -0,0 +1,41 @@
+// @flow
+
+import { wipeKeyserverStore } from 'lib/utils/keyserver-store-utils.js';
+import { resetUserSpecificState } from 'lib/utils/reducers-utils.js';
+
+import { defaultState } from './default-state.js';
+import { nonUserSpecificFieldsNative, type AppState } from './state-types.js';
+
+const persistBlacklist = [
+ 'loadingStatuses',
+ 'lifecycleState',
+ 'dimensions',
+ 'draftStore',
+ 'connectivity',
+ 'deviceOrientation',
+ 'frozen',
+ 'threadStore',
+ 'storeLoaded',
+ 'dbOpsStore',
+ 'syncedMetadataStore',
+ 'userStore',
+ 'auxUserStore',
+ 'commServicesAccessToken',
+];
+
+function handleReduxMigrationFailure(oldState: AppState): AppState {
+ const persistedNonUserSpecificFields = nonUserSpecificFieldsNative.filter(
+ field => !persistBlacklist.includes(field) || field === '_persist',
+ );
+ const stateAfterReset = resetUserSpecificState(
+ oldState,
+ defaultState,
+ persistedNonUserSpecificFields,
+ );
+ return {
+ ...stateAfterReset,
+ keyserverStore: wipeKeyserverStore(stateAfterReset.keyserverStore),
+ };
+}
+
+export { persistBlacklist, handleReduxMigrationFailure };
diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -95,7 +95,6 @@
LegacyRawThreadInfo,
MixedRawThreadInfos,
} from 'lib/types/thread-types.js';
-import { wipeKeyserverStore } from 'lib/utils/keyserver-store-utils.js';
import {
translateClientDBMessageInfoToRawMessageInfo,
translateRawMessageInfoToClientDBMessageInfo,
@@ -106,7 +105,6 @@
convertThreadStoreThreadInfosToNewIDSchema,
} from 'lib/utils/migration-utils.js';
import { entries } from 'lib/utils/objects.js';
-import { resetUserSpecificState } from 'lib/utils/reducers-utils.js';
import {
deprecatedConvertClientDBThreadInfoToRawThreadInfo,
convertRawThreadInfoToClientDBThreadInfo,
@@ -124,11 +122,14 @@
deprecatedUpdateClientDBThreadStoreThreadInfos,
} from './deprecated-client-db-utils.js';
import { migrateThreadStoreForEditThreadPermissions } from './edit-thread-permission-migration.js';
+import {
+ handleReduxMigrationFailure,
+ persistBlacklist,
+} from './handle-redux-migration-failure.js';
import { legacyUpdateRolesAndPermissions } from './legacy-update-roles-and-permissions.js';
import { persistMigrationForManagePinsThreadPermission } from './manage-pins-permission-migration.js';
import { persistMigrationToRemoveSelectRolePermissions } from './remove-select-role-permissions.js';
import type { AppState } from './state-types.js';
-import { nonUserSpecificFieldsNative } from './state-types.js';
import { unshimClientDB } from './unshim-utils.js';
import { authoritativeKeyserverID } from '../authoritative-keyserver.js';
import { commCoreModule } from '../native-modules.js';
@@ -136,38 +137,6 @@
import { isTaskCancelledError } from '../utils/error-handling.js';
import { defaultURLPrefix } from '../utils/url-utils.js';
-const persistBlacklist = [
- 'loadingStatuses',
- 'lifecycleState',
- 'dimensions',
- 'draftStore',
- 'connectivity',
- 'deviceOrientation',
- 'frozen',
- 'threadStore',
- 'storeLoaded',
- 'dbOpsStore',
- 'syncedMetadataStore',
- 'userStore',
- 'auxUserStore',
- 'commServicesAccessToken',
-];
-
-function handleReduxMigrationFailure(oldState: AppState): AppState {
- const persistedNonUserSpecificFields = nonUserSpecificFieldsNative.filter(
- field => !persistBlacklist.includes(field) || field === '_persist',
- );
- const stateAfterReset = resetUserSpecificState(
- oldState,
- defaultState,
- persistedNonUserSpecificFields,
- );
- return {
- ...stateAfterReset,
- keyserverStore: wipeKeyserverStore(stateAfterReset.keyserverStore),
- };
-}
-
const migrations = {
[1]: (state: AppState) => ({
...state,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 9:00 AM (21 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2584085
Default Alt Text
D11886.id39908.diff (3 KB)
Attached To
Mode
D11886: [native] Factor out handleReduxMigrationFailure
Attached
Detach File
Event Timeline
Log In to Comment