Changeset View
Changeset View
Standalone View
Standalone View
native/redux/persist.js
Show All 11 Lines | import { | ||||
convertInviteLinksStoreToNewIDSchema, | convertInviteLinksStoreToNewIDSchema, | ||||
convertMessageStoreToNewIDSchema, | convertMessageStoreToNewIDSchema, | ||||
convertRawMessageInfoToNewIDSchema, | convertRawMessageInfoToNewIDSchema, | ||||
convertCalendarFilterToNewIDSchema, | convertCalendarFilterToNewIDSchema, | ||||
convertConnectionInfoToNewIDSchema, | convertConnectionInfoToNewIDSchema, | ||||
} from 'lib/_generated/migration-utils.js'; | } from 'lib/_generated/migration-utils.js'; | ||||
import { extractKeyserverIDFromID } from 'lib/keyserver-conn/keyserver-call-utils.js'; | import { extractKeyserverIDFromID } from 'lib/keyserver-conn/keyserver-call-utils.js'; | ||||
import { | import { | ||||
communityStoreOpsHandlers, | |||||
type ClientDBCommunityStoreOperation, | |||||
type ReplaceCommunityOperation, | |||||
} from 'lib/ops/community-store-ops.js'; | |||||
import { | |||||
type ClientDBKeyserverStoreOperation, | type ClientDBKeyserverStoreOperation, | ||||
keyserverStoreOpsHandlers, | keyserverStoreOpsHandlers, | ||||
type ReplaceKeyserverOperation, | type ReplaceKeyserverOperation, | ||||
} from 'lib/ops/keyserver-store-ops.js'; | } from 'lib/ops/keyserver-store-ops.js'; | ||||
import { | import { | ||||
type ClientDBMessageStoreOperation, | type ClientDBMessageStoreOperation, | ||||
messageStoreOpsHandlers, | messageStoreOpsHandlers, | ||||
} from 'lib/ops/message-store-ops.js'; | } from 'lib/ops/message-store-ops.js'; | ||||
Show All 20 Lines | import { | ||||
getCommunity, | getCommunity, | ||||
assertAllThreadInfosAreLegacy, | assertAllThreadInfosAreLegacy, | ||||
} from 'lib/shared/thread-utils.js'; | } from 'lib/shared/thread-utils.js'; | ||||
import { keyserverStoreTransform } from 'lib/shared/transforms/keyserver-store-transform.js'; | import { keyserverStoreTransform } from 'lib/shared/transforms/keyserver-store-transform.js'; | ||||
import { | import { | ||||
DEPRECATED_unshimMessageStore, | DEPRECATED_unshimMessageStore, | ||||
unshimFunc, | unshimFunc, | ||||
} from 'lib/shared/unshim-utils.js'; | } from 'lib/shared/unshim-utils.js'; | ||||
import type { CommunityInfo } from 'lib/types/community-types.js'; | |||||
import { defaultEnabledApps } from 'lib/types/enabled-apps.js'; | import { defaultEnabledApps } from 'lib/types/enabled-apps.js'; | ||||
import { defaultCalendarQuery } from 'lib/types/entry-types.js'; | import { defaultCalendarQuery } from 'lib/types/entry-types.js'; | ||||
import { defaultCalendarFilters } from 'lib/types/filter-types.js'; | import { defaultCalendarFilters } from 'lib/types/filter-types.js'; | ||||
import type { KeyserverInfo } from 'lib/types/keyserver-types.js'; | import type { KeyserverInfo } from 'lib/types/keyserver-types.js'; | ||||
import { | import { | ||||
messageTypes, | messageTypes, | ||||
type MessageType, | type MessageType, | ||||
} from 'lib/types/message-types-enum.js'; | } from 'lib/types/message-types-enum.js'; | ||||
import { | import { | ||||
type LocalMessageInfo, | type LocalMessageInfo, | ||||
type MessageStore, | type MessageStore, | ||||
type MessageStoreThreads, | type MessageStoreThreads, | ||||
type RawMessageInfo, | type RawMessageInfo, | ||||
} from 'lib/types/message-types.js'; | } from 'lib/types/message-types.js'; | ||||
import { minimallyEncodeRawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; | import { minimallyEncodeRawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; | ||||
import type { RawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; | import type { RawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; | ||||
import type { | import type { | ||||
ReportStore, | ReportStore, | ||||
ClientReportCreationRequest, | ClientReportCreationRequest, | ||||
} from 'lib/types/report-types.js'; | } from 'lib/types/report-types.js'; | ||||
import { defaultConnectionInfo } from 'lib/types/socket-types.js'; | import { defaultConnectionInfo } from 'lib/types/socket-types.js'; | ||||
import { defaultGlobalThemeInfo } from 'lib/types/theme-types.js'; | import { defaultGlobalThemeInfo } from 'lib/types/theme-types.js'; | ||||
import { threadTypeIsCommunityRoot } from 'lib/types/thread-types-enum.js'; | |||||
import type { | import type { | ||||
ClientDBThreadInfo, | ClientDBThreadInfo, | ||||
LegacyRawThreadInfo, | LegacyRawThreadInfo, | ||||
MixedRawThreadInfos, | MixedRawThreadInfos, | ||||
} from 'lib/types/thread-types.js'; | } from 'lib/types/thread-types.js'; | ||||
import { wipeKeyserverStore } from 'lib/utils/keyserver-store-utils.js'; | import { wipeKeyserverStore } from 'lib/utils/keyserver-store-utils.js'; | ||||
import { | import { | ||||
translateClientDBMessageInfoToRawMessageInfo, | translateClientDBMessageInfoToRawMessageInfo, | ||||
▲ Show 20 Lines • Show All 1,035 Lines • ▼ Show 20 Lines | [63]: async (state: any) => { | ||||
} catch (exception) { | } catch (exception) { | ||||
if (isTaskCancelledError(exception)) { | if (isTaskCancelledError(exception)) { | ||||
return newState; | return newState; | ||||
} | } | ||||
return handleReduxMigrationFailure(newState); | return handleReduxMigrationFailure(newState); | ||||
} | } | ||||
return newState; | return newState; | ||||
}, | }, | ||||
[64]: async (state: AppState) => { | |||||
const clientDBThreadInfos = commCoreModule.getAllThreadsSync(); | |||||
const replaceOperations: $ReadOnlyArray<ReplaceCommunityOperation> = | |||||
clientDBThreadInfos | |||||
.filter(threadInfo => threadTypeIsCommunityRoot(threadInfo.type)) | |||||
.map(threadInfo => { | |||||
const communityInfo: CommunityInfo = { | |||||
enabledApps: defaultEnabledApps, | |||||
}; | |||||
return { | |||||
type: 'replace_community', | |||||
payload: { | |||||
id: threadInfo.id, | |||||
communityInfo, | |||||
}, | |||||
}; | |||||
}); | |||||
const dbOperations: $ReadOnlyArray<ClientDBCommunityStoreOperation> = | |||||
communityStoreOpsHandlers.convertOpsToClientDBOps([ | |||||
{ type: 'remove_all_communities' }, | |||||
...replaceOperations, | |||||
]); | |||||
try { | |||||
await commCoreModule.processCommunityStoreOperations(dbOperations); | |||||
} catch (exception) { | |||||
if (isTaskCancelledError(exception)) { | |||||
return state; | |||||
} | |||||
return handleReduxMigrationFailure(state); | |||||
} | |||||
return state; | |||||
}, | |||||
}; | }; | ||||
// After migration 31, we'll no longer want to persist `messageStore.messages` | // After migration 31, we'll no longer want to persist `messageStore.messages` | ||||
// via redux-persist. However, we DO want to continue persisting everything in | // via redux-persist. However, we DO want to continue persisting everything in | ||||
// `messageStore` EXCEPT for `messages`. The `blacklist` property in | // `messageStore` EXCEPT for `messages`. The `blacklist` property in | ||||
// `persistConfig` allows us to specify top-level keys that shouldn't be | // `persistConfig` allows us to specify top-level keys that shouldn't be | ||||
// persisted. However, we aren't able to specify nested keys in `blacklist`. | // persisted. However, we aren't able to specify nested keys in `blacklist`. | ||||
// As a result, if we want to prevent nested keys from being persisted we'll | // As a result, if we want to prevent nested keys from being persisted we'll | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | const reportStoreTransform: Transform = createTransform( | ||||
{ whitelist: ['reportStore'] }, | { whitelist: ['reportStore'] }, | ||||
); | ); | ||||
const persistConfig = { | const persistConfig = { | ||||
key: 'root', | key: 'root', | ||||
storage: AsyncStorage, | storage: AsyncStorage, | ||||
blacklist: persistBlacklist, | blacklist: persistBlacklist, | ||||
debug: __DEV__, | debug: __DEV__, | ||||
version: 63, | version: 64, | ||||
transforms: [ | transforms: [ | ||||
messageStoreMessagesBlocklistTransform, | messageStoreMessagesBlocklistTransform, | ||||
reportStoreTransform, | reportStoreTransform, | ||||
keyserverStoreTransform, | keyserverStoreTransform, | ||||
], | ], | ||||
migrate: (createAsyncMigrate(migrations, { debug: __DEV__ }): any), | migrate: (createAsyncMigrate(migrations, { debug: __DEV__ }): any), | ||||
timeout: ((__DEV__ ? 0 : undefined): number | void), | timeout: ((__DEV__ ? 0 : undefined): number | void), | ||||
}; | }; | ||||
Show All 16 Lines |