Simplify fetchCount using combineActions.

master
Tom Hacohen 7 years ago
parent 6566bc01df
commit afb940d51a

@ -1,6 +1,6 @@
import { createStore, combineReducers, applyMiddleware } from 'redux'; import { createStore, combineReducers, applyMiddleware } from 'redux';
import { persistReducer, persistStore } from 'redux-persist'; import { persistReducer, persistStore } from 'redux-persist';
import { createActions, handleAction, handleActions } from 'redux-actions'; import { createActions, handleAction, handleActions, combineActions } from 'redux-actions';
import session from 'redux-persist/lib/storage/session'; import session from 'redux-persist/lib/storage/session';
import thunkMiddleware from 'redux-thunk'; import thunkMiddleware from 'redux-thunk';
import { createLogger } from 'redux-logger'; import { createLogger } from 'redux-logger';
@ -143,20 +143,21 @@ const journals = handleAction(
{value: null} {value: null}
); );
function fetchCount(state: number = 0, action: any) { const fetchCount = handleAction(
switch (action.type) { combineActions(
case fetchCredentials.toString(): fetchCredentials,
case fetchJournals.toString(): fetchJournals,
case fetchEntries.toString(): fetchEntries
if (action.payload === undefined) { ),
return state + 1; (state: number, action: any) => {
} else { if (action.payload === undefined) {
return state - 1; return state + 1;
} } else {
default: return state - 1;
return state; }
} },
} 0
);
const credentialsPersistConfig = { const credentialsPersistConfig = {
key: 'credentials', key: 'credentials',

Loading…
Cancel
Save