mirror of
https://github.com/Lidarr/Lidarr
synced 2025-12-06 00:16:41 +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,
|
||||
artistId: PropTypes.number.isRequired,
|
||||
monitored: PropTypes.bool.isRequired,
|
||||
releaseDate: PropTypes.string.isRequired,
|
||||
releaseDate: PropTypes.string,
|
||||
mediumCount: PropTypes.number.isRequired,
|
||||
duration: PropTypes.number.isRequired,
|
||||
title: PropTypes.string.isRequired,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
/* eslint max-params: 0 */
|
||||
import _ from 'lodash';
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
|
|
@ -22,19 +20,10 @@ function createMapStateToProps() {
|
|||
createDimensionsSelector(),
|
||||
createUISettingsSelector(),
|
||||
(label, albums, artist, commands, dimensions, uiSettings) => {
|
||||
|
||||
const albumsInGroup = _.filter(albums.items, { albumType: label });
|
||||
|
||||
let sortDir = 'asc';
|
||||
|
||||
if (albums.sortDirection === 'descending') {
|
||||
sortDir = 'desc';
|
||||
}
|
||||
|
||||
const sortedAlbums = _.orderBy(albumsInGroup, albums.sortKey, sortDir);
|
||||
const albumsByType = albums.items.filter(({ albumType }) => albumType === label);
|
||||
|
||||
return {
|
||||
items: sortedAlbums,
|
||||
items: albumsByType,
|
||||
columns: albums.columns,
|
||||
artistMonitored: artist.monitored,
|
||||
sortKey: albums.sortKey,
|
||||
|
|
|
|||
|
|
@ -31,9 +31,14 @@ export const defaultState = {
|
|||
saveError: null,
|
||||
sortKey: 'releaseDate',
|
||||
sortDirection: sortDirections.DESCENDING,
|
||||
secondarySortKey: 'title',
|
||||
secondarySortDirection: sortDirections.ASCENDING,
|
||||
items: [],
|
||||
pendingChanges: {},
|
||||
sortPredicates: {
|
||||
title: ({ title }) => {
|
||||
return title.toLocaleLowerCase();
|
||||
},
|
||||
rating: function(item) {
|
||||
return item.ratings.value;
|
||||
},
|
||||
|
|
@ -41,6 +46,9 @@ export const defaultState = {
|
|||
const { statistics = {} } = item;
|
||||
|
||||
return statistics.sizeOnDisk || 0;
|
||||
},
|
||||
releaseDate: function({ releaseDate }) {
|
||||
return releaseDate || '0';
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue