mirror of
https://github.com/Lidarr/Lidarr
synced 2025-12-06 08:25:54 +01:00
Improve sorting albums in artist details
(cherry picked from commit a27ac47812368aed79929389f79bbbd3f2e47000)
This commit is contained in:
parent
323b366ac6
commit
82467fdf04
3 changed files with 11 additions and 14 deletions
|
|
@ -253,7 +253,7 @@ AlbumRow.propTypes = {
|
||||||
id: PropTypes.number.isRequired,
|
id: PropTypes.number.isRequired,
|
||||||
artistId: PropTypes.number.isRequired,
|
artistId: PropTypes.number.isRequired,
|
||||||
monitored: PropTypes.bool.isRequired,
|
monitored: PropTypes.bool.isRequired,
|
||||||
releaseDate: PropTypes.string.isRequired,
|
releaseDate: PropTypes.string,
|
||||||
mediumCount: PropTypes.number.isRequired,
|
mediumCount: PropTypes.number.isRequired,
|
||||||
duration: PropTypes.number.isRequired,
|
duration: PropTypes.number.isRequired,
|
||||||
title: PropTypes.string.isRequired,
|
title: PropTypes.string.isRequired,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
/* eslint max-params: 0 */
|
|
||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
@ -22,19 +20,10 @@ function createMapStateToProps() {
|
||||||
createDimensionsSelector(),
|
createDimensionsSelector(),
|
||||||
createUISettingsSelector(),
|
createUISettingsSelector(),
|
||||||
(label, albums, artist, commands, dimensions, uiSettings) => {
|
(label, albums, artist, commands, dimensions, uiSettings) => {
|
||||||
|
const albumsByType = albums.items.filter(({ albumType }) => albumType === label);
|
||||||
const albumsInGroup = _.filter(albums.items, { albumType: label });
|
|
||||||
|
|
||||||
let sortDir = 'asc';
|
|
||||||
|
|
||||||
if (albums.sortDirection === 'descending') {
|
|
||||||
sortDir = 'desc';
|
|
||||||
}
|
|
||||||
|
|
||||||
const sortedAlbums = _.orderBy(albumsInGroup, albums.sortKey, sortDir);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
items: sortedAlbums,
|
items: albumsByType,
|
||||||
columns: albums.columns,
|
columns: albums.columns,
|
||||||
artistMonitored: artist.monitored,
|
artistMonitored: artist.monitored,
|
||||||
sortKey: albums.sortKey,
|
sortKey: albums.sortKey,
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,14 @@ export const defaultState = {
|
||||||
saveError: null,
|
saveError: null,
|
||||||
sortKey: 'releaseDate',
|
sortKey: 'releaseDate',
|
||||||
sortDirection: sortDirections.DESCENDING,
|
sortDirection: sortDirections.DESCENDING,
|
||||||
|
secondarySortKey: 'title',
|
||||||
|
secondarySortDirection: sortDirections.ASCENDING,
|
||||||
items: [],
|
items: [],
|
||||||
pendingChanges: {},
|
pendingChanges: {},
|
||||||
sortPredicates: {
|
sortPredicates: {
|
||||||
|
title: ({ title }) => {
|
||||||
|
return title.toLocaleLowerCase();
|
||||||
|
},
|
||||||
rating: function(item) {
|
rating: function(item) {
|
||||||
return item.ratings.value;
|
return item.ratings.value;
|
||||||
},
|
},
|
||||||
|
|
@ -41,6 +46,9 @@ export const defaultState = {
|
||||||
const { statistics = {} } = item;
|
const { statistics = {} } = item;
|
||||||
|
|
||||||
return statistics.sizeOnDisk || 0;
|
return statistics.sizeOnDisk || 0;
|
||||||
|
},
|
||||||
|
releaseDate: function({ releaseDate }) {
|
||||||
|
return releaseDate || '0';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue