diff --git a/src/store/reducers.ts b/src/store/reducers.ts index 8d088c3..d277ea7 100644 --- a/src/store/reducers.ts +++ b/src/store/reducers.ts @@ -67,10 +67,17 @@ function credentialsIdentityReducer(state: CredentialsType = {value: null}, acti function fetchTypeIdentityReducer( state: Record> = fetchTypeRecord()(), action: any, extend: boolean = false) { if (action.error) { - return state.set('value', null).set('error', action.payload); + return state.set('error', action.payload); } else { const fetching = (action.payload === undefined) ? true : undefined; const payload = (action.payload === undefined) ? null : action.payload; + + state = state.set('error', undefined); + + if (fetching) { + return state.set('fetching', fetching); + } + let value = state.get('value', null); if (extend && (value !== null)) { if (payload !== null) { @@ -81,7 +88,10 @@ function fetchTypeIdentityReducer( } else { value = null; } - return state.set('value', value).set('fetching', fetching); + return state.merge({ + value, + fetching, + }); } }