Changeset View
Changeset View
Standalone View
Standalone View
web/redux/redux-setup.js
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | import { | ||||
setPrimaryIdentityKeys, | setPrimaryIdentityKeys, | ||||
setNotificationIdentityKeys, | setNotificationIdentityKeys, | ||||
setPickledNotificationAccount, | setPickledNotificationAccount, | ||||
setPickledPrimaryAccount, | setPickledPrimaryAccount, | ||||
} from './crypto-store-reducer.js'; | } from './crypto-store-reducer.js'; | ||||
import { reduceDeviceID } from './device-id-reducer.js'; | import { reduceDeviceID } from './device-id-reducer.js'; | ||||
import reduceNavInfo from './nav-reducer.js'; | import reduceNavInfo from './nav-reducer.js'; | ||||
import { getVisibility } from './visibility.js'; | import { getVisibility } from './visibility.js'; | ||||
import { databaseModule } from '../database/database-module-provider.js'; | |||||
import { filterThreadIDsBelongingToCommunity } from '../selectors/calendar-selectors.js'; | import { filterThreadIDsBelongingToCommunity } from '../selectors/calendar-selectors.js'; | ||||
import { activeThreadSelector } from '../selectors/nav-selectors.js'; | import { activeThreadSelector } from '../selectors/nav-selectors.js'; | ||||
import { type NavInfo } from '../types/nav-types.js'; | import { type NavInfo } from '../types/nav-types.js'; | ||||
import { workerRequestMessageTypes } from '../types/worker-types.js'; | |||||
export type WindowDimensions = { width: number, height: number }; | export type WindowDimensions = { width: number, height: number }; | ||||
export type AppState = { | export type AppState = { | ||||
navInfo: NavInfo, | navInfo: NavInfo, | ||||
deviceID: ?string, | deviceID: ?string, | ||||
currentUserInfo: ?CurrentUserInfo, | currentUserInfo: ?CurrentUserInfo, | ||||
draftStore: DraftStore, | draftStore: DraftStore, | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | export function reducer(oldState: AppState | void, action: Action): AppState { | ||||
if ( | if ( | ||||
action.type !== updateNavInfoActionType && | action.type !== updateNavInfoActionType && | ||||
action.type !== setDeviceIDActionType && | action.type !== setDeviceIDActionType && | ||||
action.type !== setPrimaryIdentityKeys && | action.type !== setPrimaryIdentityKeys && | ||||
action.type !== setNotificationIdentityKeys && | action.type !== setNotificationIdentityKeys && | ||||
action.type !== setPickledPrimaryAccount && | action.type !== setPickledPrimaryAccount && | ||||
action.type !== setPickledNotificationAccount | action.type !== setPickledNotificationAccount | ||||
) { | ) { | ||||
state = baseReducer(state, action).state; | const baseReducerResult = baseReducer(state, action); | ||||
state = baseReducerResult.state; | |||||
const { | |||||
storeOperations: { draftStoreOperations }, | |||||
} = baseReducerResult; | |||||
if (draftStoreOperations.length) { | |||||
(async () => { | |||||
const isSupported = await databaseModule.isDatabaseSupported(); | |||||
if (!isSupported) { | |||||
return; | |||||
} | |||||
await databaseModule.schedule({ | |||||
type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS, | |||||
storeOperations: { draftStoreOperations }, | |||||
}); | |||||
})(); | |||||
} | |||||
} | } | ||||
state = { | state = { | ||||
...state, | ...state, | ||||
navInfo: reduceNavInfo( | navInfo: reduceNavInfo( | ||||
state.navInfo, | state.navInfo, | ||||
action, | action, | ||||
state.threadStore.threadInfos, | state.threadStore.threadInfos, | ||||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |