cnap-cobre/synapse

View on GitHub
frontend/src/store/fileHistory/reducer.js

Summary

Maintainability
A
1 hr
Test Coverage
import * as types from './types';
 
export const initialFileHistoryState = {};
 
Function `fileHistory` has 31 lines of code (exceeds 25 allowed). Consider refactoring.
export default function fileHistory(state = initialFileHistoryState, action) {
const stateForPath = state[action.path] || {};
 
switch (action.type) {
case types.GET_FILE_HISTORY_ASYNC.PENDING:
return {
...state,
[action.path]: {
...stateForPath,
loading: true,
},
};
case types.GET_FILE_HISTORY_ASYNC.SUCCESS:
return {
...state,
[action.path]: {
...stateForPath,
history: action.history,
loading: false,
},
};
case types.GET_FILE_HISTORY_ASYNC.ERROR:
return {
...state,
[action.path]: {
...stateForPath,
history: [],
loading: false,
},
};
default:
return state;
}
}