Changeset View
Changeset View
Standalone View
Standalone View
native/redux/persist.js
Show All 25 Lines | |||||
import { defaultEnabledApps } from 'lib/types/enabled-apps.js'; | import { defaultEnabledApps } from 'lib/types/enabled-apps.js'; | ||||
import { defaultCalendarFilters } from 'lib/types/filter-types.js'; | import { defaultCalendarFilters } from 'lib/types/filter-types.js'; | ||||
import { messageTypes } from 'lib/types/message-types-enum.js'; | import { messageTypes } from 'lib/types/message-types-enum.js'; | ||||
import { | import { | ||||
type LocalMessageInfo, | type LocalMessageInfo, | ||||
type MessageStore, | type MessageStore, | ||||
type ClientDBMessageStoreOperation, | type ClientDBMessageStoreOperation, | ||||
} from 'lib/types/message-types.js'; | } from 'lib/types/message-types.js'; | ||||
import type { | |||||
ReportStore, | |||||
ClientReportCreationRequest, | |||||
} from 'lib/types/report-types.js'; | |||||
import { defaultConnectionInfo } from 'lib/types/socket-types.js'; | import { defaultConnectionInfo } from 'lib/types/socket-types.js'; | ||||
import type { | import type { | ||||
ClientDBThreadStoreOperation, | ClientDBThreadStoreOperation, | ||||
ClientDBThreadInfo, | ClientDBThreadInfo, | ||||
} from 'lib/types/thread-types.js'; | } from 'lib/types/thread-types.js'; | ||||
import { | import { | ||||
convertMessageStoreOperationsToClientDBOperations, | convertMessageStoreOperationsToClientDBOperations, | ||||
translateClientDBMessageInfoToRawMessageInfo, | translateClientDBMessageInfoToRawMessageInfo, | ||||
▲ Show 20 Lines • Show All 590 Lines • ▼ Show 20 Lines | (state: MessageStore): MessageStore => { | ||||
// `messageStore` before migrations are run, we need to make sure we aren't | // `messageStore` before migrations are run, we need to make sure we aren't | ||||
// inadvertently clearing `messageStore.messages` (by setting to {}) before | // inadvertently clearing `messageStore.messages` (by setting to {}) before | ||||
// messages are stored in SQLite (https://linear.app/comm/issue/ENG-2377). | // messages are stored in SQLite (https://linear.app/comm/issue/ENG-2377). | ||||
return { ...messageStore, threads, messages: messageStore.messages ?? {} }; | return { ...messageStore, threads, messages: messageStore.messages ?? {} }; | ||||
}, | }, | ||||
{ whitelist: ['messageStore'] }, | { whitelist: ['messageStore'] }, | ||||
); | ); | ||||
type PersistedReportStore = $Diff< | |||||
ReportStore, | |||||
{ +queuedReports: $ReadOnlyArray<ClientReportCreationRequest> }, | |||||
>; | |||||
const reportStoreTransform: Transform = createTransform( | |||||
(state: ReportStore): PersistedReportStore => { | |||||
return { enabledReports: state.enabledReports }; | |||||
}, | |||||
(state: PersistedReportStore): ReportStore => { | |||||
return { ...state, queuedReports: [] }; | |||||
}, | |||||
{ whitelist: ['reportStore'] }, | |||||
); | |||||
const persistConfig = { | const persistConfig = { | ||||
key: 'root', | key: 'root', | ||||
storage: AsyncStorage, | storage: AsyncStorage, | ||||
blacklist: [ | blacklist: [ | ||||
'loadingStatuses', | 'loadingStatuses', | ||||
'lifecycleState', | 'lifecycleState', | ||||
'dimensions', | 'dimensions', | ||||
'draftStore', | 'draftStore', | ||||
'connectivity', | 'connectivity', | ||||
'deviceOrientation', | 'deviceOrientation', | ||||
'frozen', | 'frozen', | ||||
'threadStore', | 'threadStore', | ||||
'storeLoaded', | 'storeLoaded', | ||||
], | ], | ||||
debug: __DEV__, | debug: __DEV__, | ||||
version: 42, | version: 42, | ||||
transforms: [messageStoreMessagesBlocklistTransform], | transforms: [messageStoreMessagesBlocklistTransform, reportStoreTransform], | ||||
migrate: (createMigrate(migrations, { debug: __DEV__ }): any), | migrate: (createMigrate(migrations, { debug: __DEV__ }): any), | ||||
timeout: ((__DEV__ ? 0 : undefined): number | void), | timeout: ((__DEV__ ? 0 : undefined): number | void), | ||||
}; | }; | ||||
const codeVersion: number = commCoreModule.getCodeVersion(); | const codeVersion: number = commCoreModule.getCodeVersion(); | ||||
// This local exists to avoid a circular dependency where redux-setup needs to | // This local exists to avoid a circular dependency where redux-setup needs to | ||||
// import all the navigation and screen stuff, but some of those screens want to | // import all the navigation and screen stuff, but some of those screens want to | ||||
Show All 11 Lines |