Changeset View
Changeset View
Standalone View
Standalone View
web/redux/redux-setup.js
// @flow | // @flow | ||||
import invariant from 'invariant'; | import invariant from 'invariant'; | ||||
import type { PersistState } from 'redux-persist/es/types.js'; | import type { PersistState } from 'redux-persist/es/types.js'; | ||||
import { | import { | ||||
logOutActionTypes, | logOutActionTypes, | ||||
deleteAccountActionTypes, | deleteAccountActionTypes, | ||||
} from 'lib/actions/user-actions.js'; | } from 'lib/actions/user-actions.js'; | ||||
import { convertReportStoreOperationToClientDBReportStoreOperation } from 'lib/ops/report-store-ops.js'; | |||||
import baseReducer from 'lib/reducers/master-reducer.js'; | import baseReducer from 'lib/reducers/master-reducer.js'; | ||||
import { mostRecentlyReadThreadSelector } from 'lib/selectors/thread-selectors.js'; | import { mostRecentlyReadThreadSelector } from 'lib/selectors/thread-selectors.js'; | ||||
import { isLoggedIn } from 'lib/selectors/user-selectors.js'; | import { isLoggedIn } from 'lib/selectors/user-selectors.js'; | ||||
import { invalidSessionDowngrade } from 'lib/shared/session-utils.js'; | import { invalidSessionDowngrade } from 'lib/shared/session-utils.js'; | ||||
import type { Shape } from 'lib/types/core.js'; | import type { Shape } from 'lib/types/core.js'; | ||||
import type { | import type { | ||||
CryptoStore, | CryptoStore, | ||||
OLMIdentityKeys, | OLMIdentityKeys, | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | if ( | ||||
action.type !== setNotificationIdentityKeys && | action.type !== setNotificationIdentityKeys && | ||||
action.type !== setPickledPrimaryAccount && | action.type !== setPickledPrimaryAccount && | ||||
action.type !== setPickledNotificationAccount | action.type !== setPickledNotificationAccount | ||||
) { | ) { | ||||
const baseReducerResult = baseReducer(state, action); | const baseReducerResult = baseReducer(state, action); | ||||
state = baseReducerResult.state; | state = baseReducerResult.state; | ||||
const { | const { | ||||
storeOperations: { draftStoreOperations }, | storeOperations: { draftStoreOperations, reportStoreOperations }, | ||||
} = baseReducerResult; | } = baseReducerResult; | ||||
if (draftStoreOperations.length) { | if (draftStoreOperations.length > 0 || reportStoreOperations.length > 0) { | ||||
(async () => { | (async () => { | ||||
const isSupported = await databaseModule.isDatabaseSupported(); | const isSupported = await databaseModule.isDatabaseSupported(); | ||||
if (!isSupported) { | if (!isSupported) { | ||||
return; | return; | ||||
} | } | ||||
const convertedReportStoreOperations = | |||||
convertReportStoreOperationToClientDBReportStoreOperation( | |||||
reportStoreOperations, | |||||
); | |||||
await databaseModule.schedule({ | await databaseModule.schedule({ | ||||
type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS, | type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS, | ||||
storeOperations: { draftStoreOperations }, | storeOperations: { | ||||
draftStoreOperations, | |||||
reportStoreOperations: convertedReportStoreOperations, | |||||
}, | |||||
}); | }); | ||||
})(); | })(); | ||||
} | } | ||||
} | } | ||||
const communityPickerStore = reduceCommunityPickerStore( | const communityPickerStore = reduceCommunityPickerStore( | ||||
state.communityPickerStore, | state.communityPickerStore, | ||||
action, | action, | ||||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |