From 286f73f38db356dd91c1d8afd3600f63def0873b Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 29 Jun 2019 22:26:02 -0400 Subject: [PATCH] Fixed: Refresh Indicator always spinning after refresh --- frontend/src/Movie/Index/MovieIndex.js | 30 +++++-- .../src/Movie/Index/MovieIndexConnector.js | 81 ++++++++++--------- .../Movie/Index/MovieIndexItemConnector.js | 2 +- .../Messaging/Commands/CommandRepository.cs | 4 +- 4 files changed, 69 insertions(+), 48 deletions(-) diff --git a/frontend/src/Movie/Index/MovieIndex.js b/frontend/src/Movie/Index/MovieIndex.js index 7e714db51..f50a3f497 100644 --- a/frontend/src/Movie/Index/MovieIndex.js +++ b/frontend/src/Movie/Index/MovieIndex.js @@ -7,12 +7,14 @@ import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import PageContent from 'Components/Page/PageContent'; import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; import PageJumpBar from 'Components/Page/PageJumpBar'; +import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator'; import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; import NoMovie from 'Movie/NoMovie'; import MovieIndexTableConnector from './Table/MovieIndexTableConnector'; +import MovieIndexTableOptionsConnector from './Table/MovieIndexTableOptionsConnector'; import MovieIndexPosterOptionsModal from './Posters/Options/MovieIndexPosterOptionsModal'; import MovieIndexPostersConnector from './Posters/MovieIndexPostersConnector'; import MovieIndexOverviewOptionsModal from './Overview/Options/MovieIndexOverviewOptionsModal'; @@ -182,6 +184,7 @@ class MovieIndex extends Component { error, totalItems, items, + columns, selectedFilterKey, filters, customFilters, @@ -251,7 +254,7 @@ class MovieIndex extends Component { @@ -262,25 +265,41 @@ class MovieIndex extends Component { alignContent={align.RIGHT} collapseButtons={false} > + { + view === 'table' ? + + + : + null + } { - view === 'posters' && + view === 'posters' ? + /> : + null } { - view === 'overview' && + view === 'overview' ? + /> : + null } { @@ -388,6 +407,7 @@ MovieIndex.propTypes = { error: PropTypes.object, totalItems: PropTypes.number.isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired, + columns: PropTypes.arrayOf(PropTypes.object).isRequired, selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, filters: PropTypes.arrayOf(PropTypes.object).isRequired, customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, diff --git a/frontend/src/Movie/Index/MovieIndexConnector.js b/frontend/src/Movie/Index/MovieIndexConnector.js index 3ef368f42..39fc1b5cb 100644 --- a/frontend/src/Movie/Index/MovieIndexConnector.js +++ b/frontend/src/Movie/Index/MovieIndexConnector.js @@ -8,7 +8,7 @@ import createCommandExecutingSelector from 'Store/Selectors/createCommandExecuti import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; import { fetchMovies } from 'Store/Actions/movieActions'; import scrollPositions from 'Store/scrollPositions'; -import { setMovieSort, setMovieFilter, setMovieView } from 'Store/Actions/movieIndexActions'; +import { setMovieSort, setMovieFilter, setMovieView, setMovieTableOption } from 'Store/Actions/movieIndexActions'; import { executeCommand } from 'Store/Actions/commandActions'; import * as commandNames from 'Commands/commandNames'; import withScrollPosition from 'Components/withScrollPosition'; @@ -59,13 +59,41 @@ function createMapStateToProps() { ); } -const mapDispatchToProps = { - fetchMovies, - setMovieSort, - setMovieFilter, - setMovieView, - executeCommand -}; +function createMapDispatchToProps(dispatch, props) { + return { + dispatchFetchMovies() { + dispatch(fetchMovies); + }, + + onTableOptionChange(payload) { + dispatch(setMovieTableOption(payload)); + }, + + onSortSelect(sortKey) { + dispatch(setMovieSort({ sortKey })); + }, + + onFilterSelect(selectedFilterKey) { + dispatch(setMovieFilter({ selectedFilterKey })); + }, + + dispatchSetMovieView(view) { + dispatch(setMovieView({ view })); + }, + + onRefreshMoviePress() { + dispatch(executeCommand({ + name: commandNames.REFRESH_MOVIE + })); + }, + + onRssSyncPress() { + dispatch(executeCommand({ + name: commandNames.RSS_SYNC + })); + } + }; +} class MovieIndexConnector extends Component { @@ -87,24 +115,16 @@ class MovieIndexConnector extends Component { } componentDidMount() { - this.props.fetchMovies(); + this.props.dispatchFetchMovies(); } // // Listeners - onSortSelect = (sortKey) => { - this.props.setMovieSort({ sortKey }); - } - - onFilterSelect = (selectedFilterKey) => { - this.props.setMovieFilter({ selectedFilterKey }); - } - onViewSelect = (view) => { // Reset the scroll position before changing the view this.setState({ scrollTop: 0 }, () => { - this.props.setMovieView({ view }); + this.props.dispatchSetMovieView(view); }); } @@ -116,18 +136,6 @@ class MovieIndexConnector extends Component { }); } - onRefreshMoviePress = () => { - this.props.executeCommand({ - name: commandNames.REFRESH_MOVIE - }); - } - - onRssSyncPress = () => { - this.props.executeCommand({ - name: commandNames.RSS_SYNC - }); - } - // // Render @@ -136,12 +144,8 @@ class MovieIndexConnector extends Component { ); } @@ -151,14 +155,11 @@ MovieIndexConnector.propTypes = { isSmallScreen: PropTypes.bool.isRequired, view: PropTypes.string.isRequired, scrollTop: PropTypes.number.isRequired, - fetchMovies: PropTypes.func.isRequired, - setMovieSort: PropTypes.func.isRequired, - setMovieFilter: PropTypes.func.isRequired, - setMovieView: PropTypes.func.isRequired, - executeCommand: PropTypes.func.isRequired + dispatchFetchMovies: PropTypes.func.isRequired, + dispatchSetMovieView: PropTypes.func.isRequired }; export default withScrollPosition( - connect(createMapStateToProps, mapDispatchToProps)(MovieIndexConnector), + connect(createMapStateToProps, createMapDispatchToProps)(MovieIndexConnector), 'movieIndex' ); diff --git a/frontend/src/Movie/Index/MovieIndexItemConnector.js b/frontend/src/Movie/Index/MovieIndexItemConnector.js index 8af687ad9..da80627e9 100644 --- a/frontend/src/Movie/Index/MovieIndexItemConnector.js +++ b/frontend/src/Movie/Index/MovieIndexItemConnector.js @@ -3,7 +3,7 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import createMovieSelector from 'Store/Selectors/createMovieSelector'; -import createExecutingCommandsSelector from 'Store/Selectors/createCommandsSelector'; +import createExecutingCommandsSelector from 'Store/Selectors/createExecutingCommandsSelector'; import createMovieQualityProfileSelector from 'Store/Selectors/createMovieQualityProfileSelector'; import { executeCommand } from 'Store/Actions/commandActions'; import * as commandNames from 'Commands/commandNames'; diff --git a/src/NzbDrone.Core/Messaging/Commands/CommandRepository.cs b/src/NzbDrone.Core/Messaging/Commands/CommandRepository.cs index 4b75faba1..173d6c6eb 100644 --- a/src/NzbDrone.Core/Messaging/Commands/CommandRepository.cs +++ b/src/NzbDrone.Core/Messaging/Commands/CommandRepository.cs @@ -64,12 +64,12 @@ namespace NzbDrone.Core.Messaging.Commands public List Queued() { - return Query.Where(c => c.Status == CommandStatus.Queued).ToList(); + return Query.Where(c => c.Status == CommandStatus.Queued); } public List Started() { - return Query.Where(c => c.Status == CommandStatus.Started).ToList(); + return Query.Where(c => c.Status == CommandStatus.Started); } public void Start(CommandModel command)