Fixed: Updates to commandExecutingSelector

pull/6/head
Qstick 6 years ago
parent 68aaa49e9f
commit e41f884153

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save