From e17aaaf79df90d96d9d88da19986be947006547c Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Dec 2017 00:55:58 +0000 Subject: [PATCH] Simplify entries fetching reducer. --- src/store.tsx | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/store.tsx b/src/store.tsx index 3b2efee..9b0405e 100644 --- a/src/store.tsx +++ b/src/store.tsx @@ -117,22 +117,9 @@ const credentials = handleActions( const entries = handleAction( fetchEntries, (state: EntriesType, action: any) => { - if (action.error) { - return { ...state, - [action.meta.journal]: { - value: null, - error: action.payload, - }, - }; - } else { - const fetching = (action.payload === undefined) ? true : undefined; - return { ...state, - [action.meta.journal]: { - fetching, - value: (action.payload === undefined) ? null : action.payload, - }, - }; - } + return { ...state, + [action.meta.journal]: fetchTypeIdentityReducer(state[action.meta.journal], action) + }; }, {} );