diff --git a/frontend/src/Series/Index/SeriesIndexItemConnector.js b/frontend/src/Series/Index/SeriesIndexItemConnector.js index 633fa722b..86173ec7e 100644 --- a/frontend/src/Series/Index/SeriesIndexItemConnector.js +++ b/frontend/src/Series/Index/SeriesIndexItemConnector.js @@ -3,9 +3,8 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { isCommandExecuting } from 'Utilities/Command'; 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 createLanguageProfileSelector from 'Store/Selectors/createLanguageProfileSelector'; import { executeCommand } from 'Store/Actions/commandActions'; @@ -35,27 +34,25 @@ function createMapStateToProps() { createQualityProfileSelector(), createLanguageProfileSelector(), selectShowSearchAction(), - createCommandsSelector(), + createExecutingCommandsSelector(), ( series, qualityProfile, languageProfile, showSearchAction, - commands + executingCommands ) => { - const isRefreshingSeries = commands.some((command) => { + const isRefreshingSeries = executingCommands.some((command) => { return ( command.name === commandNames.REFRESH_SERIES && - command.body.seriesId === series.id && - isCommandExecuting(command) + command.body.seriesId === series.id ); }); - const isSearchingSeries = commands.some((command) => { + const isSearchingSeries = executingCommands.some((command) => { return ( command.name === commandNames.SERIES_SEARCH && - command.body.seriesId === series.id && - isCommandExecuting(command) + command.body.seriesId === series.id ); }); diff --git a/frontend/src/Store/Selectors/createExecutingCommandsSelector.js b/frontend/src/Store/Selectors/createExecutingCommandsSelector.js new file mode 100644 index 000000000..266865a8a --- /dev/null +++ b/frontend/src/Store/Selectors/createExecutingCommandsSelector.js @@ -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; diff --git a/frontend/src/Store/Selectors/createSeriesSelector.js b/frontend/src/Store/Selectors/createSeriesSelector.js index 1c1ab5bb8..fc5057b95 100644 --- a/frontend/src/Store/Selectors/createSeriesSelector.js +++ b/frontend/src/Store/Selectors/createSeriesSelector.js @@ -1,4 +1,3 @@ -import _ from 'lodash'; import { createSelector } from 'reselect'; import createAllSeriesSelector from './createAllSeriesSelector'; @@ -6,8 +5,8 @@ function createSeriesSelector() { return createSelector( (state, { seriesId }) => seriesId, createAllSeriesSelector(), - (seriesId, series) => { - return _.find(series, { id: seriesId }); + (seriesId, allSeries) => { + return allSeries.find((series) => series.id === seriesId); } ); }