You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
576 B

/* eslint-disable consistent-return */
import db from 'helpers/db'
import { getAccounts } from 'reducers/accounts'
export default store => next => action => {
if (!action.type.startsWith('DB:')) {
return next(action)
}
const { dispatch, getState } = store
const [, type] = action.type.split(':')
dispatch({ type, payload: action.payload })
const state = getState()
const { settings, counterValues } = state
const accounts = getAccounts(state)
db.set('settings', settings)
db.set('accounts', accounts)
db.set('counterValues', counterValues)
}