|
|
@ -1,6 +1,7 @@
|
|
|
|
import _ from 'lodash';
|
|
|
|
import _ from 'lodash';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
|
|
|
import getRemovedItems from 'Utilities/Object/getRemovedItems';
|
|
|
|
import hasDifferentItems from 'Utilities/Object/hasDifferentItems';
|
|
|
|
import hasDifferentItems from 'Utilities/Object/hasDifferentItems';
|
|
|
|
import getSelectedIds from 'Utilities/Table/getSelectedIds';
|
|
|
|
import getSelectedIds from 'Utilities/Table/getSelectedIds';
|
|
|
|
import removeOldSelectedState from 'Utilities/Table/removeOldSelectedState';
|
|
|
|
import removeOldSelectedState from 'Utilities/Table/removeOldSelectedState';
|
|
|
@ -36,34 +37,26 @@ class Queue extends Component {
|
|
|
|
lastToggled: null,
|
|
|
|
lastToggled: null,
|
|
|
|
selectedState: {},
|
|
|
|
selectedState: {},
|
|
|
|
isPendingSelected: false,
|
|
|
|
isPendingSelected: false,
|
|
|
|
isConfirmRemoveModalOpen: false
|
|
|
|
isConfirmRemoveModalOpen: false,
|
|
|
|
|
|
|
|
items: props.items
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
shouldComponentUpdate(nextProps) {
|
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
// Don't update when fetching has completed if items have changed,
|
|
|
|
const {
|
|
|
|
// before episodes start fetching or when episodes start fetching.
|
|
|
|
items,
|
|
|
|
|
|
|
|
isEpisodesFetching
|
|
|
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
this.props.isFetching &&
|
|
|
|
(!isEpisodesFetching && prevProps.isEpisodesFetching) ||
|
|
|
|
nextProps.isPopulated &&
|
|
|
|
(hasDifferentItems(prevProps.items, items) && !items.some((e) => e.episodeId))
|
|
|
|
hasDifferentItems(this.props.items, nextProps.items) &&
|
|
|
|
|
|
|
|
nextProps.items.some((e) => e.episodeId)
|
|
|
|
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.props.isEpisodesFetching && nextProps.isEpisodesFetching) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
|
|
|
|
if (hasDifferentItems(prevProps.items, this.props.items)) {
|
|
|
|
|
|
|
|
this.setState((state) => {
|
|
|
|
this.setState((state) => {
|
|
|
|
return removeOldSelectedState(state, prevProps.items);
|
|
|
|
return {
|
|
|
|
|
|
|
|
...removeOldSelectedState(state, getRemovedItems(prevProps.items, items)),
|
|
|
|
|
|
|
|
items
|
|
|
|
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -124,7 +117,6 @@ class Queue extends Component {
|
|
|
|
isFetching,
|
|
|
|
isFetching,
|
|
|
|
isPopulated,
|
|
|
|
isPopulated,
|
|
|
|
error,
|
|
|
|
error,
|
|
|
|
items,
|
|
|
|
|
|
|
|
isEpisodesFetching,
|
|
|
|
isEpisodesFetching,
|
|
|
|
isEpisodesPopulated,
|
|
|
|
isEpisodesPopulated,
|
|
|
|
episodesError,
|
|
|
|
episodesError,
|
|
|
@ -142,7 +134,8 @@ class Queue extends Component {
|
|
|
|
allUnselected,
|
|
|
|
allUnselected,
|
|
|
|
selectedState,
|
|
|
|
selectedState,
|
|
|
|
isConfirmRemoveModalOpen,
|
|
|
|
isConfirmRemoveModalOpen,
|
|
|
|
isPendingSelected
|
|
|
|
isPendingSelected,
|
|
|
|
|
|
|
|
items
|
|
|
|
} = this.state;
|
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
|
|
|
|
const isRefreshing = isFetching || isEpisodesFetching || isRefreshMonitoredDownloadsExecuting;
|
|
|
|
const isRefreshing = isFetching || isEpisodesFetching || isRefreshMonitoredDownloadsExecuting;
|
|
|
|