diff --git a/lib/utils/migration-utils.js b/lib/utils/migration-utils.js --- a/lib/utils/migration-utils.js +++ b/lib/utils/migration-utils.js @@ -177,7 +177,7 @@ ]; export type LegacyMigrationManifest> = { - +[number | string]: (T) => Promise, + +[number | string]: (T) => Promise | T, }; type PersistedState> = T | void; type ConfigType = { diff --git a/native/redux/persist.js b/native/redux/persist.js --- a/native/redux/persist.js +++ b/native/redux/persist.js @@ -179,37 +179,41 @@ import { codeVersion } from '../version.mjs'; const legacyMigrations = { - [1]: (state: AppState) => ({ - ...state, - notifPermissionAlertInfo: defaultAlertInfo, - }), - [2]: (state: AppState) => ({ - ...state, - messageSentFromRoute: [], - }), - [3]: (state: any) => ({ - currentUserInfo: state.currentUserInfo, - entryStore: state.entryStore, - threadInfos: state.threadInfos, - userInfos: state.userInfos, - messageStore: { - ...state.messageStore, - currentAsOf: state.currentAsOf, - }, - updatesCurrentAsOf: state.currentAsOf, - cookie: state.cookie, - deviceToken: state.deviceToken, - urlPrefix: state.urlPrefix, - customServer: state.customServer, - notifPermissionAlertInfo: state.notifPermissionAlertInfo, - messageSentFromRoute: state.messageSentFromRoute, - _persist: state._persist, - }), - [4]: (state: AppState) => ({ - ...state, - pingTimestamps: undefined, - activeServerRequests: undefined, - }), + [1]: (state: AppState) => + ({ + ...state, + notifPermissionAlertInfo: defaultAlertInfo, + }) as any, + [2]: (state: AppState) => + ({ + ...state, + messageSentFromRoute: [], + }) as any, + [3]: (state: any) => + ({ + currentUserInfo: state.currentUserInfo, + entryStore: state.entryStore, + threadInfos: state.threadInfos, + userInfos: state.userInfos, + messageStore: { + ...state.messageStore, + currentAsOf: state.currentAsOf, + }, + updatesCurrentAsOf: state.currentAsOf, + cookie: state.cookie, + deviceToken: state.deviceToken, + urlPrefix: state.urlPrefix, + customServer: state.customServer, + notifPermissionAlertInfo: state.notifPermissionAlertInfo, + messageSentFromRoute: state.messageSentFromRoute, + _persist: state._persist, + }) as any, + [4]: (state: AppState) => + ({ + ...state, + pingTimestamps: undefined, + activeServerRequests: undefined, + }) as any, [5]: (state: AppState) => ({ ...state, calendarFilters: defaultCalendarFilters, @@ -222,29 +226,31 @@ inconsistencyResponses: [], }, }), - [7]: (state: AppState) => ({ - ...state, - lastUserInteraction: undefined, - sessionID: undefined, - entryStore: { - ...state.entryStore, - inconsistencyResponses: [], - }, - }), - [8]: (state: AppState) => ({ - ...state, - pingTimestamps: undefined, - activeServerRequests: undefined, - connection: { - ...defaultConnectionInfo, - actualizedCalendarQuery: defaultCalendarQuery(Platform.OS), - }, - watchedThreadIDs: [], - entryStore: { - ...state.entryStore, - actualizedCalendarQuery: undefined, - }, - }), + [7]: (state: AppState) => + ({ + ...state, + lastUserInteraction: undefined, + sessionID: undefined, + entryStore: { + ...state.entryStore, + inconsistencyResponses: [], + }, + }) as any, + [8]: (state: AppState) => + ({ + ...state, + pingTimestamps: undefined, + activeServerRequests: undefined, + connection: { + ...defaultConnectionInfo, + actualizedCalendarQuery: defaultCalendarQuery(Platform.OS), + }, + watchedThreadIDs: [], + entryStore: { + ...state.entryStore, + actualizedCalendarQuery: undefined, + }, + }) as any, [9]: (state: any) => ({ ...state, connection: { @@ -325,7 +331,7 @@ userStore: { userInfos: state.userStore.userInfos, inconsistencyReports: [], - }, + } as any, }), [19]: (state: any) => { const threadInfos: { [string]: LegacyRawThreadInfo } = {}; @@ -379,10 +385,11 @@ ...state, enabledApps: defaultEnabledApps, }), - [25]: (state: AppState) => ({ - ...state, - crashReportsEnabled: __DEV__, - }), + [25]: (state: AppState) => + ({ + ...state, + crashReportsEnabled: __DEV__, + }) as any, [26]: (state: any) => { const { currentUserInfo } = state; if (currentUserInfo.anonymous) { @@ -485,7 +492,7 @@ ...state, threadStore: { ...state.threadStore, - threadInfos: updatedThreadInfos, + threadInfos: updatedThreadInfos as any, }, }; }, @@ -513,7 +520,7 @@ if (isTaskCancelledError(exception)) { return state; } - return { ...state, cookie: null }; + return { ...state, cookie: null } as any; } return state; }, @@ -536,7 +543,7 @@ if (isTaskCancelledError(exception)) { return state; } - return { ...state, cookie: null }; + return { ...state, cookie: null } as any; } return state; }, @@ -649,7 +656,7 @@ commCoreModule.processThreadStoreOperationsSync(operations); } catch (exception) { console.log(exception); - return { ...state, cookie: null }; + return { ...state, cookie: null } as any; } return state; @@ -676,7 +683,7 @@ if (isTaskCancelledError(exception)) { return state; } - return { ...state, cookie: null }; + return { ...state, cookie: null } as any; } return state; @@ -717,7 +724,7 @@ if (isTaskCancelledError(exception)) { return state; } - return { ...state, cookie: null }; + return { ...state, cookie: null } as any; } return state; }, @@ -756,7 +763,7 @@ }); } catch (exception) { console.log(exception); - return { ...state, cookie: null }; + return { ...state, cookie: null } as any; } const inviteLinksStore = @@ -804,13 +811,14 @@ }; }, [46]: async (state: AppState) => { - const { currentAsOf } = state.messageStore; - return { ...state, messageStore: { ...state.messageStore, - currentAsOf: { [authoritativeKeyserverID]: currentAsOf }, + currentAsOf: { + ...state.messageStore.currentAsOf, + [authoritativeKeyserverID]: 0, + }, }, }; }, @@ -861,12 +869,12 @@ keyserverInfos: { ...keyserverStore.keyserverInfos, [authoritativeKeyserverID]: { - ...keyserverRest, + ...(keyserverRest as any), }, }, }, connection, - }; + } as any; }, [50]: async (state: any) => { const { connection, ...rest } = state; @@ -1252,7 +1260,7 @@ }, [68]: async (state: AppState) => { const { userStore, ...rest } = state; - return rest; + return rest as any; }, [69]: (state: any) => { const { notifPermissionAlertInfo, ...rest } = state;