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.
|
|
|
/* 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 } = state
|
|
|
|
|
|
|
|
db.set('settings', settings)
|
|
|
|
db.set('accounts', getAccounts(state))
|
|
|
|
}
|