mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-13 02:07:12 -07:00
Fixed: Sorting by title and release dates in Select Album modal
Fixes #5145 Closes #5125 Co-authored-by: Mark McDowall <mark@mcdowall.ca>
This commit is contained in:
parent
3a5012655e
commit
bd7d25f963
5 changed files with 143 additions and 70 deletions
86
frontend/src/Store/Actions/albumSelectionActions.js
Normal file
86
frontend/src/Store/Actions/albumSelectionActions.js
Normal file
|
@ -0,0 +1,86 @@
|
|||
import moment from 'moment';
|
||||
import { createAction } from 'redux-actions';
|
||||
import { sortDirections } from 'Helpers/Props';
|
||||
import { createThunk, handleThunks } from 'Store/thunks';
|
||||
import updateSectionState from 'Utilities/State/updateSectionState';
|
||||
import createFetchHandler from './Creators/createFetchHandler';
|
||||
import createHandleActions from './Creators/createHandleActions';
|
||||
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
|
||||
|
||||
//
|
||||
// Variables
|
||||
|
||||
export const section = 'albumSelection';
|
||||
|
||||
//
|
||||
// State
|
||||
|
||||
export const defaultState = {
|
||||
isFetching: false,
|
||||
isReprocessing: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
sortKey: 'title',
|
||||
sortDirection: sortDirections.ASCENDING,
|
||||
items: [],
|
||||
sortPredicates: {
|
||||
title: ({ title }) => {
|
||||
return title.toLocaleLowerCase();
|
||||
},
|
||||
|
||||
releaseDate: function({ releaseDate }, direction) {
|
||||
if (releaseDate) {
|
||||
return moment(releaseDate).unix();
|
||||
}
|
||||
|
||||
if (direction === sortDirections.DESCENDING) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Number.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const persistState = [
|
||||
'albumSelection.sortKey',
|
||||
'albumSelection.sortDirection'
|
||||
];
|
||||
|
||||
//
|
||||
// Actions Types
|
||||
|
||||
export const FETCH_ALBUMS = 'albumSelection/fetchAlbums';
|
||||
export const SET_ALBUMS_SORT = 'albumSelection/setAlbumsSort';
|
||||
export const CLEAR_ALBUMS = 'albumSelection/clearAlbums';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
|
||||
export const fetchAlbums = createThunk(FETCH_ALBUMS);
|
||||
export const setAlbumsSort = createAction(SET_ALBUMS_SORT);
|
||||
export const clearAlbums = createAction(CLEAR_ALBUMS);
|
||||
|
||||
//
|
||||
// Action Handlers
|
||||
|
||||
export const actionHandlers = handleThunks({
|
||||
[FETCH_ALBUMS]: createFetchHandler(section, '/album')
|
||||
});
|
||||
|
||||
//
|
||||
// Reducers
|
||||
|
||||
export const reducers = createHandleActions({
|
||||
|
||||
[SET_ALBUMS_SORT]: createSetClientSideCollectionSortReducer(section),
|
||||
|
||||
[CLEAR_ALBUMS]: (state) => {
|
||||
return updateSectionState(state, section, {
|
||||
...defaultState,
|
||||
sortKey: state.sortKey,
|
||||
sortDirection: state.sortDirection
|
||||
});
|
||||
}
|
||||
|
||||
}, defaultState, section);
|
|
@ -1,5 +1,6 @@
|
|||
import * as albums from './albumActions';
|
||||
import * as albumHistory from './albumHistoryActions';
|
||||
import * as albumSelection from './albumSelectionActions';
|
||||
import * as app from './appActions';
|
||||
import * as artist from './artistActions';
|
||||
import * as artistHistory from './artistHistoryActions';
|
||||
|
@ -29,14 +30,18 @@ import * as wanted from './wantedActions';
|
|||
|
||||
export default [
|
||||
app,
|
||||
albums,
|
||||
albumHistory,
|
||||
albumSelection,
|
||||
artist,
|
||||
artistHistory,
|
||||
artistIndex,
|
||||
blocklist,
|
||||
captcha,
|
||||
calendar,
|
||||
commands,
|
||||
customFilters,
|
||||
albums,
|
||||
trackFiles,
|
||||
albumHistory,
|
||||
history,
|
||||
interactiveImportActions,
|
||||
oAuth,
|
||||
|
@ -47,9 +52,6 @@ export default [
|
|||
providerOptions,
|
||||
queue,
|
||||
releases,
|
||||
artist,
|
||||
artistHistory,
|
||||
artistIndex,
|
||||
search,
|
||||
settings,
|
||||
system,
|
||||
|
|
|
@ -16,7 +16,6 @@ import createSetClientSideCollectionSortReducer from './Creators/Reducers/create
|
|||
|
||||
export const section = 'interactiveImport';
|
||||
|
||||
const albumsSection = `${section}.albums`;
|
||||
const trackFilesSection = `${section}.trackFiles`;
|
||||
let abortCurrentFetchRequest = null;
|
||||
let abortCurrentRequest = null;
|
||||
|
@ -58,15 +57,6 @@ export const defaultState = {
|
|||
}
|
||||
},
|
||||
|
||||
albums: {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
sortKey: 'albumTitle',
|
||||
sortDirection: sortDirections.ASCENDING,
|
||||
items: []
|
||||
},
|
||||
|
||||
trackFiles: {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
|
@ -97,10 +87,6 @@ export const ADD_RECENT_FOLDER = 'interactiveImport/addRecentFolder';
|
|||
export const REMOVE_RECENT_FOLDER = 'interactiveImport/removeRecentFolder';
|
||||
export const SET_INTERACTIVE_IMPORT_MODE = 'interactiveImport/setInteractiveImportMode';
|
||||
|
||||
export const FETCH_INTERACTIVE_IMPORT_ALBUMS = 'interactiveImport/fetchInteractiveImportAlbums';
|
||||
export const SET_INTERACTIVE_IMPORT_ALBUMS_SORT = 'interactiveImport/clearInteractiveImportAlbumsSort';
|
||||
export const CLEAR_INTERACTIVE_IMPORT_ALBUMS = 'interactiveImport/clearInteractiveImportAlbums';
|
||||
|
||||
export const FETCH_INTERACTIVE_IMPORT_TRACKFILES = 'interactiveImport/fetchInteractiveImportTrackFiles';
|
||||
export const CLEAR_INTERACTIVE_IMPORT_TRACKFILES = 'interactiveImport/clearInteractiveImportTrackFiles';
|
||||
|
||||
|
@ -117,10 +103,6 @@ export const addRecentFolder = createAction(ADD_RECENT_FOLDER);
|
|||
export const removeRecentFolder = createAction(REMOVE_RECENT_FOLDER);
|
||||
export const setInteractiveImportMode = createAction(SET_INTERACTIVE_IMPORT_MODE);
|
||||
|
||||
export const fetchInteractiveImportAlbums = createThunk(FETCH_INTERACTIVE_IMPORT_ALBUMS);
|
||||
export const setInteractiveImportAlbumsSort = createAction(SET_INTERACTIVE_IMPORT_ALBUMS_SORT);
|
||||
export const clearInteractiveImportAlbums = createAction(CLEAR_INTERACTIVE_IMPORT_ALBUMS);
|
||||
|
||||
export const fetchInteractiveImportTrackFiles = createThunk(FETCH_INTERACTIVE_IMPORT_TRACKFILES);
|
||||
export const clearInteractiveImportTrackFiles = createAction(CLEAR_INTERACTIVE_IMPORT_TRACKFILES);
|
||||
|
||||
|
@ -253,8 +235,6 @@ export const actionHandlers = handleThunks({
|
|||
});
|
||||
},
|
||||
|
||||
[FETCH_INTERACTIVE_IMPORT_ALBUMS]: createFetchHandler(albumsSection, '/album'),
|
||||
|
||||
[FETCH_INTERACTIVE_IMPORT_TRACKFILES]: createFetchHandler(trackFilesSection, '/trackFile')
|
||||
});
|
||||
|
||||
|
@ -336,14 +316,6 @@ export const reducers = createHandleActions({
|
|||
return Object.assign({}, state, { importMode: payload.importMode });
|
||||
},
|
||||
|
||||
[SET_INTERACTIVE_IMPORT_ALBUMS_SORT]: createSetClientSideCollectionSortReducer(albumsSection),
|
||||
|
||||
[CLEAR_INTERACTIVE_IMPORT_ALBUMS]: (state) => {
|
||||
return updateSectionState(state, albumsSection, {
|
||||
...defaultState.albums
|
||||
});
|
||||
},
|
||||
|
||||
[CLEAR_INTERACTIVE_IMPORT_TRACKFILES]: (state) => {
|
||||
return updateSectionState(state, trackFilesSection, {
|
||||
...defaultState.trackFiles
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue