1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00

Better selection of executing commands in series list

This commit is contained in:
Mark McDowall 2019-04-04 18:38:19 -07:00
parent e5f264a510
commit 8087996c8e
3 changed files with 22 additions and 13 deletions

View File

@ -3,9 +3,8 @@ 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 { isCommandExecuting } from 'Utilities/Command';
import createSeriesSelector from 'Store/Selectors/createSeriesSelector'; import createSeriesSelector from 'Store/Selectors/createSeriesSelector';
import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createExecutingCommandsSelector from 'Store/Selectors/createCommandsSelector';
import createQualityProfileSelector from 'Store/Selectors/createQualityProfileSelector'; import createQualityProfileSelector from 'Store/Selectors/createQualityProfileSelector';
import createLanguageProfileSelector from 'Store/Selectors/createLanguageProfileSelector'; import createLanguageProfileSelector from 'Store/Selectors/createLanguageProfileSelector';
import { executeCommand } from 'Store/Actions/commandActions'; import { executeCommand } from 'Store/Actions/commandActions';
@ -35,27 +34,25 @@ function createMapStateToProps() {
createQualityProfileSelector(), createQualityProfileSelector(),
createLanguageProfileSelector(), createLanguageProfileSelector(),
selectShowSearchAction(), selectShowSearchAction(),
createCommandsSelector(), createExecutingCommandsSelector(),
( (
series, series,
qualityProfile, qualityProfile,
languageProfile, languageProfile,
showSearchAction, showSearchAction,
commands executingCommands
) => { ) => {
const isRefreshingSeries = commands.some((command) => { const isRefreshingSeries = executingCommands.some((command) => {
return ( return (
command.name === commandNames.REFRESH_SERIES && command.name === commandNames.REFRESH_SERIES &&
command.body.seriesId === series.id && command.body.seriesId === series.id
isCommandExecuting(command)
); );
}); });
const isSearchingSeries = commands.some((command) => { const isSearchingSeries = executingCommands.some((command) => {
return ( return (
command.name === commandNames.SERIES_SEARCH && command.name === commandNames.SERIES_SEARCH &&
command.body.seriesId === series.id && command.body.seriesId === series.id
isCommandExecuting(command)
); );
}); });

View File

@ -0,0 +1,13 @@
import { createSelector } from 'reselect';
import { isCommandExecuting } from 'Utilities/Command';
function createExecutingCommandsSelector() {
return createSelector(
(state) => state.commands.items,
(commands) => {
return commands.filter((command) => isCommandExecuting(command));
}
);
}
export default createExecutingCommandsSelector;

View File

@ -1,4 +1,3 @@
import _ from 'lodash';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import createAllSeriesSelector from './createAllSeriesSelector'; import createAllSeriesSelector from './createAllSeriesSelector';
@ -6,8 +5,8 @@ function createSeriesSelector() {
return createSelector( return createSelector(
(state, { seriesId }) => seriesId, (state, { seriesId }) => seriesId,
createAllSeriesSelector(), createAllSeriesSelector(),
(seriesId, series) => { (seriesId, allSeries) => {
return _.find(series, { id: seriesId }); return allSeries.find((series) => series.id === seriesId);
} }
); );
} }