2017-09-04 02:20:56 +00:00
|
|
|
import { handleActions } from 'redux-actions';
|
|
|
|
import getSectionState from 'Utilities/State/getSectionState';
|
|
|
|
import updateSectionState from 'Utilities/State/updateSectionState';
|
|
|
|
import * as types from 'Store/Actions/actionTypes';
|
|
|
|
import createSetReducer from './Creators/createSetReducer';
|
|
|
|
import createSetSettingValueReducer from './Creators/createSetSettingValueReducer';
|
|
|
|
import createUpdateReducer from './Creators/createUpdateReducer';
|
|
|
|
import createUpdateItemReducer from './Creators/createUpdateItemReducer';
|
|
|
|
import createRemoveItemReducer from './Creators/createRemoveItemReducer';
|
|
|
|
|
|
|
|
export const defaultState = {
|
|
|
|
isFetching: false,
|
|
|
|
isPopulated: false,
|
|
|
|
error: null,
|
|
|
|
isAdding: false,
|
|
|
|
isAdded: false,
|
|
|
|
addError: null,
|
|
|
|
items: [],
|
|
|
|
|
|
|
|
defaults: {
|
|
|
|
rootFolderPath: '',
|
|
|
|
monitor: 'allEpisodes',
|
|
|
|
qualityProfileId: 0,
|
|
|
|
languageProfileId: 0,
|
|
|
|
seriesType: 'standard',
|
2017-10-07 04:13:00 +00:00
|
|
|
primaryAlbumTypes: 'Studio, Single',
|
|
|
|
secondaryAlbumTypes: '',
|
2017-09-04 02:20:56 +00:00
|
|
|
albumFolder: true,
|
|
|
|
tags: []
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const persistState = [
|
2017-09-08 03:09:52 +00:00
|
|
|
'addArtist.defaults'
|
2017-09-04 02:20:56 +00:00
|
|
|
];
|
|
|
|
|
2017-09-08 03:09:52 +00:00
|
|
|
const reducerSection = 'addArtist';
|
2017-09-04 02:20:56 +00:00
|
|
|
|
2017-09-08 03:09:52 +00:00
|
|
|
const addArtistReducers = handleActions({
|
2017-09-04 02:20:56 +00:00
|
|
|
|
|
|
|
[types.SET]: createSetReducer(reducerSection),
|
|
|
|
[types.UPDATE]: createUpdateReducer(reducerSection),
|
|
|
|
[types.UPDATE_ITEM]: createUpdateItemReducer(reducerSection),
|
|
|
|
[types.REMOVE_ITEM]: createRemoveItemReducer(reducerSection),
|
|
|
|
|
2017-09-08 03:09:52 +00:00
|
|
|
[types.SET_ADD_ARTIST_VALUE]: createSetSettingValueReducer(reducerSection),
|
2017-09-04 02:20:56 +00:00
|
|
|
|
2017-09-08 03:09:52 +00:00
|
|
|
[types.SET_ADD_ARTIST_DEFAULT]: function(state, { payload }) {
|
2017-09-04 02:20:56 +00:00
|
|
|
const newState = getSectionState(state, reducerSection);
|
|
|
|
|
|
|
|
newState.defaults = {
|
|
|
|
...newState.defaults,
|
|
|
|
...payload
|
|
|
|
};
|
|
|
|
|
|
|
|
return updateSectionState(state, reducerSection, newState);
|
|
|
|
},
|
|
|
|
|
2017-09-08 03:09:52 +00:00
|
|
|
[types.CLEAR_ADD_ARTIST]: function(state) {
|
2017-09-04 02:20:56 +00:00
|
|
|
const {
|
|
|
|
defaults,
|
|
|
|
...otherDefaultState
|
|
|
|
} = defaultState;
|
|
|
|
|
|
|
|
return Object.assign({}, state, otherDefaultState);
|
|
|
|
}
|
|
|
|
|
|
|
|
}, defaultState);
|
|
|
|
|
2017-09-08 03:09:52 +00:00
|
|
|
export default addArtistReducers;
|