mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
Sort tags by label
Co-authored-by: Mark McDowall <markus.mcd5@gmail.com> (cherry picked from commit f32a3cd41c17bb9cb829ac24732cfeec6a18d569) Fixes #8531
This commit is contained in:
parent
bb77538701
commit
3feaee25e2
@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { kinds } from 'Helpers/Props';
|
import { kinds } from 'Helpers/Props';
|
||||||
@ -6,16 +5,15 @@ import Label from './Label';
|
|||||||
import styles from './TagList.css';
|
import styles from './TagList.css';
|
||||||
|
|
||||||
function TagList({ tags, tagList }) {
|
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 (
|
return (
|
||||||
<div className={styles.tags}>
|
<div className={styles.tags}>
|
||||||
{
|
{
|
||||||
tags.map((t) => {
|
sortedTags.map((tag) => {
|
||||||
const tag = _.find(tagList, { id: t });
|
|
||||||
|
|
||||||
if (!tag) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Label
|
<Label
|
||||||
key={tag.id}
|
key={tag.id}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import createMovieSelector from 'Store/Selectors/createMovieSelector';
|
import createMovieSelector from 'Store/Selectors/createMovieSelector';
|
||||||
@ -10,15 +9,11 @@ function createMapStateToProps() {
|
|||||||
createMovieSelector(),
|
createMovieSelector(),
|
||||||
createTagsSelector(),
|
createTagsSelector(),
|
||||||
(movie, tagList) => {
|
(movie, tagList) => {
|
||||||
const tags = _.reduce(movie.tags, (acc, tag) => {
|
const tags = movie.tags
|
||||||
const matchingTag = _.find(tagList, { id: tag });
|
.map((tagId) => tagList.find((tag) => tag.id === tagId))
|
||||||
|
.filter((tag) => !!tag)
|
||||||
if (matchingTag) {
|
.map((tag) => tag.label)
|
||||||
acc.push(matchingTag.label);
|
.sort((a, b) => a.localeCompare(b));
|
||||||
}
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tags
|
tags
|
||||||
|
Loading…
Reference in New Issue
Block a user