mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-30 03:38:26 -07:00
Fix Interactive Import, Add Track Actions and Reducers
This commit is contained in:
parent
8f45fe0afe
commit
90d9741056
13 changed files with 193 additions and 27 deletions
|
@ -84,6 +84,14 @@ export const CLEAR_EPISODES = 'CLEAR_EPISODES';
|
|||
export const TOGGLE_EPISODE_MONITORED = 'TOGGLE_EPISODE_MONITORED';
|
||||
export const TOGGLE_EPISODES_MONITORED = 'TOGGLE_EPISODES_MONITORED';
|
||||
|
||||
//
|
||||
// Tracks
|
||||
|
||||
export const FETCH_TRACKS = 'FETCH_TRACKS';
|
||||
export const SET_TRACKS_SORT = 'SET_TRACKS_SORT';
|
||||
export const SET_TRACKS_TABLE_OPTION = 'SET_TRACKS_TABLE_OPTION';
|
||||
export const CLEAR_TRACKS = 'CLEAR_TRACKS';
|
||||
|
||||
//
|
||||
// Episode Files
|
||||
|
||||
|
|
11
frontend/src/Store/Actions/trackActionHandlers.js
Normal file
11
frontend/src/Store/Actions/trackActionHandlers.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import createFetchHandler from './Creators/createFetchHandler';
|
||||
import * as types from './actionTypes';
|
||||
|
||||
const section = 'tracks';
|
||||
|
||||
const trackActionHandlers = {
|
||||
[types.FETCH_TRACKS]: createFetchHandler(section, '/track')
|
||||
|
||||
};
|
||||
|
||||
export default trackActionHandlers;
|
8
frontend/src/Store/Actions/trackActions.js
Normal file
8
frontend/src/Store/Actions/trackActions.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { createAction } from 'redux-actions';
|
||||
import * as types from './actionTypes';
|
||||
import trackActionHandlers from './trackActionHandlers';
|
||||
|
||||
export const fetchTracks = trackActionHandlers[types.FETCH_TRACKS];
|
||||
export const setTracksSort = createAction(types.SET_TRACKS_SORT);
|
||||
export const setTracksTableOption = createAction(types.SET_TRACKS_TABLE_OPTION);
|
||||
export const clearTracks = createAction(types.CLEAR_TRACKS);
|
|
@ -2,6 +2,7 @@ import _ from 'lodash';
|
|||
import persistState from 'redux-localstorage';
|
||||
import * as addArtistReducers from 'Store/Reducers/addArtistReducers';
|
||||
import * as episodeReducers from 'Store/Reducers/episodeReducers';
|
||||
import * as trackReducers from 'Store/Reducers/trackReducers';
|
||||
import * as artistIndexReducers from 'Store/Reducers/artistIndexReducers';
|
||||
import * as artistEditorReducers from 'Store/Reducers/artistEditorReducers';
|
||||
import * as albumStudioReducers from 'Store/Reducers/albumStudioReducers';
|
||||
|
@ -17,6 +18,7 @@ import * as queueReducers from 'Store/Reducers/queueReducers';
|
|||
const reducers = [
|
||||
addArtistReducers,
|
||||
episodeReducers,
|
||||
trackReducers,
|
||||
artistIndexReducers,
|
||||
artistEditorReducers,
|
||||
albumStudioReducers,
|
||||
|
|
|
@ -13,6 +13,7 @@ import history, { defaultState as defaultHistoryState } from './historyReducers'
|
|||
import queue, { defaultState as defaultQueueState } from './queueReducers';
|
||||
import blacklist, { defaultState as defaultBlacklistState } from './blacklistReducers';
|
||||
import episodes, { defaultState as defaultEpisodesState } from './episodeReducers';
|
||||
import tracks, { defaultState as defaultTracksState } from './trackReducers';
|
||||
import episodeFiles, { defaultState as defaultEpisodeFilesState } from './episodeFileReducers';
|
||||
import albumHistory, { defaultState as defaultAlbumHistoryState } from './albumHistoryReducers';
|
||||
import releases, { defaultState as defaultReleasesState } from './releaseReducers';
|
||||
|
@ -41,6 +42,7 @@ export const defaultState = {
|
|||
queue: defaultQueueState,
|
||||
blacklist: defaultBlacklistState,
|
||||
episodes: defaultEpisodesState,
|
||||
tracks: defaultTracksState,
|
||||
episodeFiles: defaultEpisodeFilesState,
|
||||
albumHistory: defaultAlbumHistoryState,
|
||||
releases: defaultReleasesState,
|
||||
|
@ -70,6 +72,7 @@ export default enableBatching(combineReducers({
|
|||
queue,
|
||||
blacklist,
|
||||
episodes,
|
||||
tracks,
|
||||
episodeFiles,
|
||||
albumHistory,
|
||||
releases,
|
||||
|
|
70
frontend/src/Store/Reducers/trackReducers.js
Normal file
70
frontend/src/Store/Reducers/trackReducers.js
Normal file
|
@ -0,0 +1,70 @@
|
|||
import { handleActions } from 'redux-actions';
|
||||
import * as types from 'Store/Actions/actionTypes';
|
||||
import { sortDirections } from 'Helpers/Props';
|
||||
import createSetReducer from './Creators/createSetReducer';
|
||||
import createSetTableOptionReducer from './Creators/createSetTableOptionReducer';
|
||||
import createUpdateReducer from './Creators/createUpdateReducer';
|
||||
import createUpdateItemReducer from './Creators/createUpdateItemReducer';
|
||||
import createSetClientSideCollectionSortReducer from './Creators/createSetClientSideCollectionSortReducer';
|
||||
|
||||
export const defaultState = {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
sortKey: 'trackNumber',
|
||||
sortDirection: sortDirections.DESCENDING,
|
||||
items: [],
|
||||
|
||||
columns: [
|
||||
{
|
||||
name: 'trackNumber',
|
||||
label: 'Track Number',
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'title',
|
||||
label: 'Title',
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'duration',
|
||||
label: 'Duration',
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'actions',
|
||||
columnLabel: 'Actions',
|
||||
isVisible: true,
|
||||
isModifiable: false
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export const persistState = [
|
||||
'tracks.columns'
|
||||
];
|
||||
|
||||
const reducerSection = 'tracks';
|
||||
|
||||
const trackReducers = handleActions({
|
||||
|
||||
[types.SET]: createSetReducer(reducerSection),
|
||||
[types.UPDATE]: createUpdateReducer(reducerSection),
|
||||
[types.UPDATE_ITEM]: createUpdateItemReducer(reducerSection),
|
||||
|
||||
[types.SET_TRACKS_TABLE_OPTION]: createSetTableOptionReducer(reducerSection),
|
||||
|
||||
[types.CLEAR_TRACKS]: (state) => {
|
||||
return Object.assign({}, state, {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
items: []
|
||||
});
|
||||
},
|
||||
|
||||
[types.SET_TRACKS_SORT]: createSetClientSideCollectionSortReducer(reducerSection)
|
||||
|
||||
}, defaultState);
|
||||
|
||||
export default trackReducers;
|
14
frontend/src/Store/Selectors/createTrackSelector.js
Normal file
14
frontend/src/Store/Selectors/createTrackSelector.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
import _ from 'lodash';
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
function createTrackSelector() {
|
||||
return createSelector(
|
||||
(state, { trackId }) => trackId,
|
||||
(state) => state.tracks,
|
||||
(trackId, tracks) => {
|
||||
return _.find(tracks.items, { id: trackId });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default createTrackSelector;
|
Loading…
Add table
Add a link
Reference in a new issue