Fixed: Updates to commandExecutingSelector

This commit is contained in:
Qstick 2018-09-04 22:40:26 -04:00
parent 68aaa49e9f
commit e41f884153
16 changed files with 57 additions and 73 deletions

View file

@ -1,10 +1,9 @@
import _ from 'lodash';
import PropTypes from 'prop-types'; 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 { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator';
import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
import * as blacklistActions from 'Store/Actions/blacklistActions'; import * as blacklistActions from 'Store/Actions/blacklistActions';
import { executeCommand } from 'Store/Actions/commandActions'; import { executeCommand } from 'Store/Actions/commandActions';
import * as commandNames from 'Commands/commandNames'; import * as commandNames from 'Commands/commandNames';
@ -13,10 +12,8 @@ import Blacklist from './Blacklist';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.blacklist, (state) => state.blacklist,
createCommandsSelector(), createCommandExecutingSelector(commandNames.CLEAR_BLACKLIST),
(blacklist, commands) => { (blacklist, isClearingBlacklistExecuting) => {
const isClearingBlacklistExecuting = _.some(commands, { name: commandNames.CLEAR_BLACKLIST });
return { return {
isClearingBlacklistExecuting, isClearingBlacklistExecuting,
...blacklist ...blacklist

View file

@ -6,7 +6,7 @@ import { createSelector } from 'reselect';
import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator';
import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems';
import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; import selectUniqueIds from 'Utilities/Object/selectUniqueIds';
import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
import { executeCommand } from 'Store/Actions/commandActions'; import { executeCommand } from 'Store/Actions/commandActions';
import * as queueActions from 'Store/Actions/queueActions'; import * as queueActions from 'Store/Actions/queueActions';
import { fetchAlbums, clearAlbums } from 'Store/Actions/albumActions'; import { fetchAlbums, clearAlbums } from 'Store/Actions/albumActions';
@ -17,10 +17,8 @@ function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.albums, (state) => state.albums,
(state) => state.queue.paged, (state) => state.queue.paged,
createCommandsSelector(), createCommandExecutingSelector(commandNames.CHECK_FOR_FINISHED_DOWNLOAD),
(albums, queue, commands) => { (albums, queue, isCheckForFinishedDownloadExecuting) => {
const isCheckForFinishedDownloadExecuting = _.some(commands, { name: commandNames.CHECK_FOR_FINISHED_DOWNLOAD });
return { return {
isAlbumsFetching: albums.isFetching, isAlbumsFetching: albums.isFetching,
isAlbumsPopulated: albums.isPopulated, isAlbumsPopulated: albums.isPopulated,

View file

@ -1,6 +1,6 @@
import _ from 'lodash';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { isCommandExecuting } from 'Utilities/Command';
import createArtistSelector from 'Store/Selectors/createArtistSelector'; import createArtistSelector from 'Store/Selectors/createArtistSelector';
import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createCommandsSelector from 'Store/Selectors/createCommandsSelector';
import { executeCommand } from 'Store/Actions/commandActions'; import { executeCommand } from 'Store/Actions/commandActions';
@ -13,14 +13,17 @@ function createMapStateToProps() {
createArtistSelector(), createArtistSelector(),
createCommandsSelector(), createCommandsSelector(),
(albumId, artist, commands) => { (albumId, artist, commands) => {
const isSearching = _.some(commands, (command) => { const isSearching = commands.some((command) => {
const albumSearch = command.name === commandNames.ALBUM_SEARCH; const albumSearch = command.name === commandNames.ALBUM_SEARCH;
if (!albumSearch) { if (!albumSearch) {
return false; return false;
} }
return command.body.albumIds.indexOf(albumId) > -1; return (
isCommandExecuting(command) &&
command.body.albumIds.indexOf(albumId) > -1
);
}); });
return { return {

View file

@ -3,17 +3,13 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import createArtistSelector from 'Store/Selectors/createArtistSelector'; import createArtistSelector from 'Store/Selectors/createArtistSelector';
import createTrackFileSelector from 'Store/Selectors/createTrackFileSelector'; import createTrackFileSelector from 'Store/Selectors/createTrackFileSelector';
import createCommandsSelector from 'Store/Selectors/createCommandsSelector';
import AlbumRow from './AlbumRow'; import AlbumRow from './AlbumRow';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state, { id }) => id,
(state, { sceneSeasonNumber }) => sceneSeasonNumber,
createArtistSelector(), createArtistSelector(),
createTrackFileSelector(), createTrackFileSelector(),
createCommandsSelector(), (artist, trackFile) => {
(id, sceneSeasonNumber, artist, trackFile, commands) => {
return { return {
foreignArtistId: artist.foreignArtistId, foreignArtistId: artist.foreignArtistId,
artistMonitored: artist.monitored, artistMonitored: artist.monitored,

View file

@ -4,6 +4,7 @@ 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 createArtistSelector from 'Store/Selectors/createArtistSelector'; import createArtistSelector from 'Store/Selectors/createArtistSelector';
import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createCommandsSelector from 'Store/Selectors/createCommandsSelector';
import createQualityProfileSelector from 'Store/Selectors/createQualityProfileSelector'; import createQualityProfileSelector from 'Store/Selectors/createQualityProfileSelector';
@ -20,9 +21,12 @@ function createMapStateToProps() {
createMetadataProfileSelector(), createMetadataProfileSelector(),
createCommandsSelector(), createCommandsSelector(),
(artist, qualityProfile, languageProfile, metadataProfile, commands) => { (artist, qualityProfile, languageProfile, metadataProfile, commands) => {
const isRefreshingArtist = _.some(commands, (command) => { const isRefreshingArtist = commands.some((command) => {
return command.name === commandNames.REFRESH_ARTIST && return (
command.body.artistId === artist.id; command.name === commandNames.REFRESH_ARTIST &&
command.body.artistId === artist.id &&
isCommandExecuting(command)
);
}); });
const latestAlbum = _.maxBy(artist.albums, (album) => album.releaseDate); const latestAlbum = _.maxBy(artist.albums, (album) => album.releaseDate);

View file

@ -6,6 +6,10 @@
color: inherit; color: inherit;
} }
.info {
color: $infoColor;
}
.success { .success {
color: $successColor; color: $successColor;
} }

View file

@ -1,10 +1,9 @@
import _ from 'lodash';
import PropTypes from 'prop-types'; 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 createSettingsSectionSelector from 'Store/Selectors/createSettingsSectionSelector'; import createSettingsSectionSelector from 'Store/Selectors/createSettingsSectionSelector';
import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
import createSystemStatusSelector from 'Store/Selectors/createSystemStatusSelector'; import createSystemStatusSelector from 'Store/Selectors/createSystemStatusSelector';
import { setGeneralSettingsValue, saveGeneralSettings, fetchGeneralSettings } from 'Store/Actions/settingsActions'; import { setGeneralSettingsValue, saveGeneralSettings, fetchGeneralSettings } from 'Store/Actions/settingsActions';
import { clearPendingChanges } from 'Store/Actions/baseActions'; import { clearPendingChanges } from 'Store/Actions/baseActions';
@ -19,11 +18,9 @@ function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.settings.advancedSettings, (state) => state.settings.advancedSettings,
createSettingsSectionSelector(SECTION), createSettingsSectionSelector(SECTION),
createCommandsSelector(), createCommandExecutingSelector(commandNames.RESET_API_KEY),
createSystemStatusSelector(), createSystemStatusSelector(),
(advancedSettings, sectionSettings, commands, systemStatus) => { (advancedSettings, sectionSettings, isResettingApiKey, systemStatus) => {
const isResettingApiKey = _.some(commands, { name: commandNames.RESET_API_KEY });
return { return {
advancedSettings, advancedSettings,
isResettingApiKey, isResettingApiKey,

View file

@ -1,12 +1,11 @@
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { findCommand, isCommandExecuting } from 'Utilities/Command'; import { isCommandExecuting } from 'Utilities/Command';
import createCommandsSelector from './createCommandsSelector'; import createCommandSelector from './createCommandSelector';
function createCommandExecutingSelector(name, contraints = {}) { function createCommandExecutingSelector(name, contraints = {}) {
return createSelector( return createSelector(
createCommandsSelector(), createCommandSelector(name, contraints),
(commands) => { (command) => {
const command = findCommand(commands, { name, ...contraints });
return isCommandExecuting(command); return isCommandExecuting(command);
} }
); );

View file

@ -6,7 +6,7 @@ function createCommandSelector(name, contraints = {}) {
return createSelector( return createSelector(
createCommandsSelector(), createCommandsSelector(),
(commands) => { (commands) => {
return !!findCommand(commands, { name, ...contraints }); return findCommand(commands, { name, ...contraints });
} }
); );
} }

View file

@ -1,9 +1,8 @@
import _ from 'lodash';
import PropTypes from 'prop-types'; 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 createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
import { fetchBackups, deleteBackup } from 'Store/Actions/systemActions'; import { fetchBackups, deleteBackup } from 'Store/Actions/systemActions';
import { executeCommand } from 'Store/Actions/commandActions'; import { executeCommand } from 'Store/Actions/commandActions';
import * as commandNames from 'Commands/commandNames'; import * as commandNames from 'Commands/commandNames';
@ -12,8 +11,8 @@ import Backups from './Backups';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.system.backups, (state) => state.system.backups,
createCommandsSelector(), createCommandExecutingSelector(commandNames.BACKUP),
(backups, commands) => { (backups, backupExecuting) => {
const { const {
isFetching, isFetching,
isPopulated, isPopulated,
@ -21,8 +20,6 @@ function createMapStateToProps() {
items items
} = backups; } = backups;
const backupExecuting = _.some(commands, { name: commandNames.BACKUP });
return { return {
isFetching, isFetching,
isPopulated, isPopulated,

View file

@ -1,9 +1,8 @@
import _ from 'lodash';
import PropTypes from 'prop-types'; 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 createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
import { executeCommand } from 'Store/Actions/commandActions'; import { executeCommand } from 'Store/Actions/commandActions';
import * as systemActions from 'Store/Actions/systemActions'; import * as systemActions from 'Store/Actions/systemActions';
import * as commandNames from 'Commands/commandNames'; import * as commandNames from 'Commands/commandNames';
@ -12,10 +11,8 @@ import LogsTable from './LogsTable';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.system.logs, (state) => state.system.logs,
createCommandsSelector(), createCommandExecutingSelector(commandNames.CLEAR_LOGS),
(logs, commands) => { (logs, clearLogExecuting) => {
const clearLogExecuting = _.some(commands, { name: commandNames.CLEAR_LOGS });
return { return {
clearLogExecuting, clearLogExecuting,
...logs ...logs

View file

@ -1,10 +1,9 @@
import _ from 'lodash';
import PropTypes from 'prop-types'; 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 combinePath from 'Utilities/String/combinePath'; import combinePath from 'Utilities/String/combinePath';
import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
import { executeCommand } from 'Store/Actions/commandActions'; import { executeCommand } from 'Store/Actions/commandActions';
import { fetchLogFiles } from 'Store/Actions/systemActions'; import { fetchLogFiles } from 'Store/Actions/systemActions';
import * as commandNames from 'Commands/commandNames'; import * as commandNames from 'Commands/commandNames';
@ -14,8 +13,8 @@ function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.system.logFiles, (state) => state.system.logFiles,
(state) => state.system.status.item, (state) => state.system.status.item,
createCommandsSelector(), createCommandExecutingSelector(commandNames.DELETE_LOG_FILES),
(logFiles, status, commands) => { (logFiles, status, deleteFilesExecuting) => {
const { const {
isFetching, isFetching,
items items
@ -26,8 +25,6 @@ function createMapStateToProps() {
isWindows isWindows
} = status; } = status;
const deleteFilesExecuting = _.some(commands, { name: commandNames.DELETE_LOG_FILES });
return { return {
isFetching, isFetching,
items, items,

View file

@ -1,10 +1,9 @@
import _ from 'lodash';
import PropTypes from 'prop-types'; 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 combinePath from 'Utilities/String/combinePath'; import combinePath from 'Utilities/String/combinePath';
import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
import { executeCommand } from 'Store/Actions/commandActions'; import { executeCommand } from 'Store/Actions/commandActions';
import { fetchUpdateLogFiles } from 'Store/Actions/systemActions'; import { fetchUpdateLogFiles } from 'Store/Actions/systemActions';
import * as commandNames from 'Commands/commandNames'; import * as commandNames from 'Commands/commandNames';
@ -14,15 +13,13 @@ function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.system.updateLogFiles, (state) => state.system.updateLogFiles,
(state) => state.system.status.item, (state) => state.system.status.item,
createCommandsSelector(), createCommandExecutingSelector(commandNames.DELETE_UPDATE_LOG_FILES),
(updateLogFiles, status, commands) => { (updateLogFiles, status, deleteFilesExecuting) => {
const { const {
isFetching, isFetching,
items items
} = updateLogFiles; } = updateLogFiles;
const deleteFilesExecuting = _.some(commands, { name: commandNames.DELETE_UPDATE_LOG_FILES });
const { const {
appData, appData,
isWindows isWindows

View file

@ -7,7 +7,7 @@ import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePo
import getFilterValue from 'Utilities/Filter/getFilterValue'; import getFilterValue from 'Utilities/Filter/getFilterValue';
import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems';
import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; import selectUniqueIds from 'Utilities/Object/selectUniqueIds';
import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
import * as wantedActions from 'Store/Actions/wantedActions'; import * as wantedActions from 'Store/Actions/wantedActions';
import { executeCommand } from 'Store/Actions/commandActions'; import { executeCommand } from 'Store/Actions/commandActions';
import { fetchQueueDetails, clearQueueDetails } from 'Store/Actions/queueActions'; import { fetchQueueDetails, clearQueueDetails } from 'Store/Actions/queueActions';
@ -18,9 +18,8 @@ import CutoffUnmet from './CutoffUnmet';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.wanted.cutoffUnmet, (state) => state.wanted.cutoffUnmet,
createCommandsSelector(), createCommandExecutingSelector(commandNames.CUTOFF_UNMET_ALBUM_SEARCH),
(cutoffUnmet, commands) => { (cutoffUnmet, isSearchingForCutoffUnmetAlbums) => {
const isSearchingForCutoffUnmetAlbums = _.some(commands, { name: commandNames.CUTOFF_UNMET_ALBUM_SEARCH });
return { return {
isSearchingForCutoffUnmetAlbums, isSearchingForCutoffUnmetAlbums,

View file

@ -7,7 +7,7 @@ import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePo
import getFilterValue from 'Utilities/Filter/getFilterValue'; import getFilterValue from 'Utilities/Filter/getFilterValue';
import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems';
import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; import selectUniqueIds from 'Utilities/Object/selectUniqueIds';
import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
import * as wantedActions from 'Store/Actions/wantedActions'; import * as wantedActions from 'Store/Actions/wantedActions';
import { executeCommand } from 'Store/Actions/commandActions'; import { executeCommand } from 'Store/Actions/commandActions';
import { fetchQueueDetails, clearQueueDetails } from 'Store/Actions/queueActions'; import { fetchQueueDetails, clearQueueDetails } from 'Store/Actions/queueActions';
@ -17,9 +17,8 @@ import Missing from './Missing';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.wanted.missing, (state) => state.wanted.missing,
createCommandsSelector(), createCommandExecutingSelector(commandNames.MISSING_ALBUM_SEARCH),
(missing, commands) => { (missing, isSearchingForMissingAlbums) => {
const isSearchingForMissingAlbums = _.some(commands, { name: commandNames.MISSING_ALBUM_SEARCH });
return { return {
isSearchingForMissingAlbums, isSearchingForMissingAlbums,

View file

@ -79,15 +79,9 @@ namespace Lidarr.Api.V1.Commands
{ {
_pendingUpdates[message.Command.Id] = message.Command.ToResource(); _pendingUpdates[message.Command.Id] = message.Command.ToResource();
} }
_debouncer.Execute(); _debouncer.Execute();
} }
if (message.Command.Name == typeof(MessagingCleanupCommand).Name.Replace("Command", "") &&
message.Command.Status == CommandStatus.Completed)
{
BroadcastResourceChange(ModelAction.Sync);
}
} }
private void SendUpdates() private void SendUpdates()
@ -100,6 +94,12 @@ namespace Lidarr.Api.V1.Commands
foreach (var pendingUpdate in pendingUpdates) foreach (var pendingUpdate in pendingUpdates)
{ {
BroadcastResourceChange(ModelAction.Updated, pendingUpdate); BroadcastResourceChange(ModelAction.Updated, pendingUpdate);
if (pendingUpdate.Name == typeof(MessagingCleanupCommand).Name.Replace("Command", "") &&
pendingUpdate.Status == CommandStatus.Completed)
{
BroadcastResourceChange(ModelAction.Sync);
}
} }
} }
} }