Fixed: Editing provider/profile settings appearing to affect wrong item

pull/6/head
ta264 5 years ago
parent 2e6094beb6
commit b54d556e63

@ -4,12 +4,13 @@ import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import sortByName from 'Utilities/Array/sortByName'; import sortByName from 'Utilities/Array/sortByName';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import { metadataProfileNames } from 'Helpers/Props'; import { metadataProfileNames } from 'Helpers/Props';
import SelectInput from './SelectInput'; import SelectInput from './SelectInput';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.settings.metadataProfiles, createSortedSectionSelector('settings.metadataProfiles', sortByName),
(state, { includeNoChange }) => includeNoChange, (state, { includeNoChange }) => includeNoChange,
(state, { includeMixed }) => includeMixed, (state, { includeMixed }) => includeMixed,
(state, { includeNone }) => includeNone, (state, { includeNone }) => includeNone,
@ -18,7 +19,7 @@ function createMapStateToProps() {
const profiles = metadataProfiles.items.filter((item) => item.name !== metadataProfileNames.NONE); const profiles = metadataProfiles.items.filter((item) => item.name !== metadataProfileNames.NONE);
const noneProfile = metadataProfiles.items.find((item) => item.name === metadataProfileNames.NONE); const noneProfile = metadataProfiles.items.find((item) => item.name === metadataProfileNames.NONE);
const values = _.map(profiles.sort(sortByName), (metadataProfile) => { const values = _.map(profiles, (metadataProfile) => {
return { return {
key: metadataProfile.id, key: metadataProfile.id,
value: metadataProfile.name value: metadataProfile.name

@ -4,15 +4,16 @@ import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import sortByName from 'Utilities/Array/sortByName'; import sortByName from 'Utilities/Array/sortByName';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import SelectInput from './SelectInput'; import SelectInput from './SelectInput';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.settings.qualityProfiles, createSortedSectionSelector('settings.qualityProfiles', sortByName),
(state, { includeNoChange }) => includeNoChange, (state, { includeNoChange }) => includeNoChange,
(state, { includeMixed }) => includeMixed, (state, { includeMixed }) => includeMixed,
(qualityProfiles, includeNoChange, includeMixed) => { (qualityProfiles, includeNoChange, includeMixed) => {
const values = _.map(qualityProfiles.items.sort(sortByName), (qualityProfile) => { const values = _.map(qualityProfiles.items, (qualityProfile) => {
return { return {
key: qualityProfile.id, key: qualityProfile.id,
value: qualityProfile.name value: qualityProfile.name

@ -12,7 +12,7 @@ function createMapStateToProps() {
createAllArtistSelector(), createAllArtistSelector(),
(items) => { (items) => {
return { return {
items: items.sort((a, b) => { items: [...items].sort((a, b) => {
if (a.sortName < b.sortName) { if (a.sortName < b.sortName) {
return -1; return -1;
} }

@ -1,6 +1,5 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import sortByName from 'Utilities/Array/sortByName';
import { icons } from 'Helpers/Props'; import { icons } from 'Helpers/Props';
import FieldSet from 'Components/FieldSet'; import FieldSet from 'Components/FieldSet';
import Card from 'Components/Card'; import Card from 'Components/Card';
@ -66,7 +65,7 @@ class DownloadClients extends Component {
> >
<div className={styles.downloadClients}> <div className={styles.downloadClients}>
{ {
items.sort(sortByName).map((item) => { items.map((item) => {
return ( return (
<DownloadClient <DownloadClient
key={item.id} key={item.id}

@ -2,17 +2,15 @@ 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';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import sortByName from 'Utilities/Array/sortByName';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import { fetchDownloadClients, deleteDownloadClient } from 'Store/Actions/settingsActions'; import { fetchDownloadClients, deleteDownloadClient } from 'Store/Actions/settingsActions';
import DownloadClients from './DownloadClients'; import DownloadClients from './DownloadClients';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.settings.downloadClients, createSortedSectionSelector('settings.downloadClients', sortByName),
(downloadClients) => { (downloadClients) => downloadClients
return {
...downloadClients
};
}
); );
} }

@ -1,6 +1,5 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import sortByName from 'Utilities/Array/sortByName';
import { icons } from 'Helpers/Props'; import { icons } from 'Helpers/Props';
import FieldSet from 'Components/FieldSet'; import FieldSet from 'Components/FieldSet';
import Card from 'Components/Card'; import Card from 'Components/Card';
@ -68,7 +67,7 @@ class ImportLists extends Component {
> >
<div className={styles.lists}> <div className={styles.lists}>
{ {
items.sort(sortByName).map((item) => { items.map((item) => {
return ( return (
<ImportList <ImportList
key={item.id} key={item.id}

@ -2,18 +2,16 @@ 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';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import sortByName from 'Utilities/Array/sortByName';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import { fetchImportLists, deleteImportList } from 'Store/Actions/settingsActions'; import { fetchImportLists, deleteImportList } from 'Store/Actions/settingsActions';
import { fetchRootFolders } from 'Store/Actions/rootFolderActions'; import { fetchRootFolders } from 'Store/Actions/rootFolderActions';
import ImportLists from './ImportLists'; import ImportLists from './ImportLists';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.settings.importLists, createSortedSectionSelector('settings.importLists', sortByName),
(importLists) => { (importLists) => importLists
return {
...importLists
};
}
); );
} }

@ -1,6 +1,5 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import sortByName from 'Utilities/Array/sortByName';
import { icons } from 'Helpers/Props'; import { icons } from 'Helpers/Props';
import FieldSet from 'Components/FieldSet'; import FieldSet from 'Components/FieldSet';
import Card from 'Components/Card'; import Card from 'Components/Card';
@ -66,7 +65,7 @@ class Indexers extends Component {
> >
<div className={styles.indexers}> <div className={styles.indexers}>
{ {
items.sort(sortByName).map((item) => { items.map((item) => {
return ( return (
<Indexer <Indexer
key={item.id} key={item.id}

@ -2,17 +2,15 @@ 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';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import sortByName from 'Utilities/Array/sortByName';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import { fetchIndexers, deleteIndexer } from 'Store/Actions/settingsActions'; import { fetchIndexers, deleteIndexer } from 'Store/Actions/settingsActions';
import Indexers from './Indexers'; import Indexers from './Indexers';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.settings.indexers, createSortedSectionSelector('settings.indexers', sortByName),
(indexers) => { (indexers) => indexers
return {
...indexers
};
}
); );
} }

@ -1,6 +1,5 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import sortByName from 'Utilities/Array/sortByName';
import FieldSet from 'Components/FieldSet'; import FieldSet from 'Components/FieldSet';
import PageSectionContent from 'Components/Page/PageSectionContent'; import PageSectionContent from 'Components/Page/PageSectionContent';
import Metadata from './Metadata'; import Metadata from './Metadata';
@ -20,7 +19,7 @@ function Metadatas(props) {
> >
<div className={styles.metadatas}> <div className={styles.metadatas}>
{ {
items.sort(sortByName).map((item) => { items.map((item) => {
return ( return (
<Metadata <Metadata
key={item.id} key={item.id}

@ -2,17 +2,15 @@ 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';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import sortByName from 'Utilities/Array/sortByName';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import { fetchMetadata } from 'Store/Actions/settingsActions'; import { fetchMetadata } from 'Store/Actions/settingsActions';
import Metadatas from './Metadatas'; import Metadatas from './Metadatas';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.settings.metadata, createSortedSectionSelector('settings.metadata', sortByName),
(metadata) => { (metadata) => metadata
return {
...metadata
};
}
); );
} }

@ -1,6 +1,5 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import sortByName from 'Utilities/Array/sortByName';
import { icons } from 'Helpers/Props'; import { icons } from 'Helpers/Props';
import FieldSet from 'Components/FieldSet'; import FieldSet from 'Components/FieldSet';
import Card from 'Components/Card'; import Card from 'Components/Card';
@ -66,7 +65,7 @@ class Notifications extends Component {
> >
<div className={styles.notifications}> <div className={styles.notifications}>
{ {
items.sort(sortByName).map((item) => { items.map((item) => {
return ( return (
<Notification <Notification
key={item.id} key={item.id}

@ -2,17 +2,15 @@ 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';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import sortByName from 'Utilities/Array/sortByName';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import { fetchNotifications, deleteNotification } from 'Store/Actions/settingsActions'; import { fetchNotifications, deleteNotification } from 'Store/Actions/settingsActions';
import Notifications from './Notifications'; import Notifications from './Notifications';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.settings.notifications, createSortedSectionSelector('settings.notifications', sortByName),
(notifications) => { (notifications) => notifications
return {
...notifications
};
}
); );
} }

@ -1,6 +1,5 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import sortByName from 'Utilities/Array/sortByName';
import { icons } from 'Helpers/Props'; import { icons } from 'Helpers/Props';
import FieldSet from 'Components/FieldSet'; import FieldSet from 'Components/FieldSet';
import Card from 'Components/Card'; import Card from 'Components/Card';
@ -58,7 +57,7 @@ class QualityProfiles extends Component {
> >
<div className={styles.qualityProfiles}> <div className={styles.qualityProfiles}>
{ {
items.sort(sortByName).map((item) => { items.map((item) => {
return ( return (
<QualityProfile <QualityProfile
key={item.id} key={item.id}

@ -2,17 +2,15 @@ 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';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import sortByName from 'Utilities/Array/sortByName';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import { fetchQualityProfiles, deleteQualityProfile, cloneQualityProfile } from 'Store/Actions/settingsActions'; import { fetchQualityProfiles, deleteQualityProfile, cloneQualityProfile } from 'Store/Actions/settingsActions';
import QualityProfiles from './QualityProfiles'; import QualityProfiles from './QualityProfiles';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.settings.qualityProfiles, createSortedSectionSelector('settings.qualityProfiles', sortByName),
(qualityProfiles) => { (qualityProfiles) => qualityProfiles
return {
...qualityProfiles
};
}
); );
} }

@ -0,0 +1,16 @@
import { createSelector } from 'reselect';
import getSectionState from 'Utilities/State/getSectionState';
function createSortedSectionSelector(section, comparer) {
return createSelector(
(state) => state,
(state) => {
const sectionState = getSectionState(state, section, true);
return {
...sectionState,
items: [...sectionState.items].sort(comparer)
};
}
);
}
export default createSortedSectionSelector;
Loading…
Cancel
Save