mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-11 07:37:10 -07:00
* New: Manually Edit/Override Album Release * !fixup for comments, loading all albums instead of only artist albums * fixup! UI Cleanup lint issues * fixup! Remove AddAlbum service for now, fix refresh override selected release * fixup! Last one... to fix updating albums with custom release set Closes #109 Closes #129 Closes #128
130 lines
2.8 KiB
JavaScript
130 lines
2.8 KiB
JavaScript
import { createAction } from 'redux-actions';
|
|
import { sortDirections } from 'Helpers/Props';
|
|
import { createThunk, handleThunks } from 'Store/thunks';
|
|
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
|
|
import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer';
|
|
import createFetchHandler from './Creators/createFetchHandler';
|
|
import createHandleActions from './Creators/createHandleActions';
|
|
|
|
//
|
|
// Variables
|
|
|
|
export const section = 'tracks';
|
|
|
|
//
|
|
// State
|
|
|
|
export const defaultState = {
|
|
isFetching: false,
|
|
isPopulated: false,
|
|
error: null,
|
|
sortKey: 'mediumNumber',
|
|
sortDirection: sortDirections.DESCENDING,
|
|
secondarySortKey: 'absoluteTrackNumber',
|
|
secondarySortDirection: sortDirections.ASCENDING,
|
|
items: [],
|
|
|
|
columns: [
|
|
{
|
|
name: 'medium',
|
|
label: 'Medium',
|
|
isVisible: false
|
|
},
|
|
{
|
|
name: 'absoluteTrackNumber',
|
|
label: 'Track',
|
|
isVisible: true
|
|
},
|
|
{
|
|
name: 'title',
|
|
label: 'Title',
|
|
isVisible: true
|
|
},
|
|
{
|
|
name: 'path',
|
|
label: 'Path',
|
|
isVisible: false
|
|
},
|
|
{
|
|
name: 'relativePath',
|
|
label: 'Relative Path',
|
|
isVisible: false
|
|
},
|
|
{
|
|
name: 'duration',
|
|
label: 'Duration',
|
|
isVisible: true
|
|
},
|
|
{
|
|
name: 'language',
|
|
label: 'Language',
|
|
isVisible: false
|
|
},
|
|
{
|
|
name: 'audioInfo',
|
|
label: 'Audio Info',
|
|
isVisible: true
|
|
},
|
|
{
|
|
name: 'status',
|
|
label: 'Status',
|
|
isVisible: true
|
|
},
|
|
{
|
|
name: 'actions',
|
|
columnLabel: 'Actions',
|
|
isVisible: true,
|
|
isModifiable: false
|
|
}
|
|
]
|
|
};
|
|
|
|
export const persistState = [
|
|
'tracks.sortKey',
|
|
'tracks.sortDirection',
|
|
'tracks.columns'
|
|
];
|
|
|
|
//
|
|
// Actions Types
|
|
|
|
export const FETCH_TRACKS = 'tracks/fetchTracks';
|
|
export const SET_TRACKS_SORT = 'tracks/setTracksSort';
|
|
export const SET_TRACKS_TABLE_OPTION = 'tracks/setTracksTableOption';
|
|
export const CLEAR_TRACKS = 'tracks/clearTracks';
|
|
|
|
//
|
|
// Action Creators
|
|
|
|
export const fetchTracks = createThunk(FETCH_TRACKS);
|
|
export const setTracksSort = createAction(SET_TRACKS_SORT);
|
|
export const setTracksTableOption = createAction(SET_TRACKS_TABLE_OPTION);
|
|
export const clearTracks = createAction(CLEAR_TRACKS);
|
|
|
|
//
|
|
// Action Handlers
|
|
|
|
export const actionHandlers = handleThunks({
|
|
[FETCH_TRACKS]: createFetchHandler(section, '/track')
|
|
|
|
});
|
|
|
|
//
|
|
// Reducers
|
|
|
|
export const reducers = createHandleActions({
|
|
|
|
[SET_TRACKS_TABLE_OPTION]: createSetTableOptionReducer(section),
|
|
|
|
[FETCH_TRACKS]: (state) => {
|
|
return Object.assign({}, state, {
|
|
isFetching: false,
|
|
isPopulated: false,
|
|
error: null,
|
|
items: []
|
|
});
|
|
},
|
|
|
|
[SET_TRACKS_SORT]: createSetClientSideCollectionSortReducer(section)
|
|
|
|
}, defaultState, section);
|