mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-02 21:15:05 +00:00
Sort tags by label
Co-authored-by: Mark McDowall <markus.mcd5@gmail.com> (cherry picked from commit f32a3cd41c17bb9cb829ac24732cfeec6a18d569) Fixes #3678
This commit is contained in:
parent
a0c095e853
commit
1ba1dbea09
2 changed files with 11 additions and 18 deletions
|
@ -1,4 +1,3 @@
|
|||
import _ from 'lodash';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import createArtistSelector from 'Store/Selectors/createArtistSelector';
|
||||
|
@ -10,15 +9,11 @@ function createMapStateToProps() {
|
|||
createArtistSelector(),
|
||||
createTagsSelector(),
|
||||
(artist, tagList) => {
|
||||
const tags = _.reduce(artist.tags, (acc, tag) => {
|
||||
const matchingTag = _.find(tagList, { id: tag });
|
||||
|
||||
if (matchingTag) {
|
||||
acc.push(matchingTag.label);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
const tags = artist.tags
|
||||
.map((tagId) => tagList.find((tag) => tag.id === tagId))
|
||||
.filter((tag) => !!tag)
|
||||
.map((tag) => tag.label)
|
||||
.sort((a, b) => a.localeCompare(b));
|
||||
|
||||
return {
|
||||
tags
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import _ from 'lodash';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import { kinds } from 'Helpers/Props';
|
||||
|
@ -6,16 +5,15 @@ import Label from './Label';
|
|||
import styles from './TagList.css';
|
||||
|
||||
function TagList({ tags, tagList }) {
|
||||
const sortedTags = tags
|
||||
.map((tagId) => tagList.find((tag) => tag.id === tagId))
|
||||
.filter((tag) => !!tag)
|
||||
.sort((a, b) => a.label.localeCompare(b.label));
|
||||
|
||||
return (
|
||||
<div className={styles.tags}>
|
||||
{
|
||||
tags.map((t) => {
|
||||
const tag = _.find(tagList, { id: t });
|
||||
|
||||
if (!tag) {
|
||||
return null;
|
||||
}
|
||||
|
||||
sortedTags.map((tag) => {
|
||||
return (
|
||||
<Label
|
||||
key={tag.id}
|
||||
|
|
Loading…
Reference in a new issue