Fixed: Error refreshing page in Activity/Wanted

pull/1689/head
ta264 4 years ago committed by Qstick
parent 2639374243
commit ddef74edde

@ -22,6 +22,8 @@ class Blacklist extends Component {
const { const {
isFetching, isFetching,
isPopulated, isPopulated,
isArtistFetching,
isArtistPopulated,
error, error,
items, items,
columns, columns,
@ -31,6 +33,9 @@ class Blacklist extends Component {
...otherProps ...otherProps
} = this.props; } = this.props;
const isAllPopulated = isPopulated && isArtistPopulated;
const isAnyFetching = isFetching || isArtistFetching;
return ( return (
<PageContent title="Blacklist"> <PageContent title="Blacklist">
<PageToolbar> <PageToolbar>
@ -58,24 +63,24 @@ class Blacklist extends Component {
<PageContentBody> <PageContentBody>
{ {
isFetching && !isPopulated && isAnyFetching && !isAllPopulated &&
<LoadingIndicator /> <LoadingIndicator />
} }
{ {
!isFetching && !!error && !isAnyFetching && !!error &&
<div>Unable to load blacklist</div> <div>Unable to load blacklist</div>
} }
{ {
isPopulated && !error && !items.length && isAllPopulated && !error && !items.length &&
<div> <div>
No history blacklist No history blacklist
</div> </div>
} }
{ {
isPopulated && !error && !!items.length && isAllPopulated && !error && !!items.length &&
<div> <div>
<Table <Table
columns={columns} columns={columns}
@ -110,6 +115,8 @@ class Blacklist extends Component {
} }
Blacklist.propTypes = { Blacklist.propTypes = {
isArtistFetching: PropTypes.bool.isRequired,
isArtistPopulated: PropTypes.bool.isRequired,
isFetching: PropTypes.bool.isRequired, isFetching: PropTypes.bool.isRequired,
isPopulated: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired,
error: PropTypes.object, error: PropTypes.object,

@ -13,9 +13,12 @@ import Blacklist from './Blacklist';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.blacklist, (state) => state.blacklist,
(state) => state.artist,
createCommandExecutingSelector(commandNames.CLEAR_BLACKLIST), createCommandExecutingSelector(commandNames.CLEAR_BLACKLIST),
(blacklist, isClearingBlacklistExecuting) => { (blacklist, artist, isClearingBlacklistExecuting) => {
return { return {
isArtistFetching: artist.isFetching,
isArtistPopulated: artist.isPopulated,
isClearingBlacklistExecuting, isClearingBlacklistExecuting,
...blacklist ...blacklist
}; };

@ -51,6 +51,8 @@ class History extends Component {
selectedFilterKey, selectedFilterKey,
filters, filters,
totalRecords, totalRecords,
isArtistFetching,
isArtistPopulated,
isAlbumsFetching, isAlbumsFetching,
isAlbumsPopulated, isAlbumsPopulated,
albumsError, albumsError,
@ -59,8 +61,8 @@ class History extends Component {
...otherProps ...otherProps
} = this.props; } = this.props;
const isFetchingAny = isFetching || isAlbumsFetching; const isFetchingAny = isFetching || isArtistFetching || isAlbumsFetching;
const isAllPopulated = isPopulated && (isAlbumsPopulated || !items.length); const isAllPopulated = isPopulated && ((isArtistPopulated && isAlbumsPopulated) || !items.length);
const hasError = error || albumsError; const hasError = error || albumsError;
return ( return (
@ -162,6 +164,8 @@ History.propTypes = {
selectedFilterKey: PropTypes.string.isRequired, selectedFilterKey: PropTypes.string.isRequired,
filters: PropTypes.arrayOf(PropTypes.object).isRequired, filters: PropTypes.arrayOf(PropTypes.object).isRequired,
totalRecords: PropTypes.number, totalRecords: PropTypes.number,
isArtistFetching: PropTypes.bool.isRequired,
isArtistPopulated: PropTypes.bool.isRequired,
isAlbumsFetching: PropTypes.bool.isRequired, isAlbumsFetching: PropTypes.bool.isRequired,
isAlbumsPopulated: PropTypes.bool.isRequired, isAlbumsPopulated: PropTypes.bool.isRequired,
albumsError: PropTypes.object, albumsError: PropTypes.object,

@ -14,10 +14,13 @@ import History from './History';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.history, (state) => state.history,
(state) => state.artist,
(state) => state.albums, (state) => state.albums,
(state) => state.tracks, (state) => state.tracks,
(history, albums, tracks) => { (history, artist, albums, tracks) => {
return { return {
isArtistFetching: artist.isFetching,
isArtistPopulated: artist.isPopulated,
isAlbumsFetching: albums.isFetching, isAlbumsFetching: albums.isFetching,
isAlbumsPopulated: albums.isPopulated, isAlbumsPopulated: albums.isPopulated,
albumsError: albums.error, albumsError: albums.error,

@ -125,6 +125,8 @@ class Queue extends Component {
isPopulated, isPopulated,
error, error,
items, items,
isArtistFetching,
isArtistPopulated,
isAlbumsFetching, isAlbumsFetching,
isAlbumsPopulated, isAlbumsPopulated,
albumsError, albumsError,
@ -145,8 +147,8 @@ class Queue extends Component {
isPendingSelected isPendingSelected
} = this.state; } = this.state;
const isRefreshing = isFetching || isAlbumsFetching || isRefreshMonitoredDownloadsExecuting; const isRefreshing = isFetching || isArtistFetching || isAlbumsFetching || isRefreshMonitoredDownloadsExecuting;
const isAllPopulated = isPopulated && (isAlbumsPopulated || !items.length || items.every((e) => !e.albumId)); const isAllPopulated = isPopulated && ((isArtistPopulated && isAlbumsPopulated) || !items.length || items.every((e) => !e.albumId));
const hasError = error || albumsError; const hasError = error || albumsError;
const selectedIds = this.getSelectedIds(); const selectedIds = this.getSelectedIds();
const selectedCount = selectedIds.length; const selectedCount = selectedIds.length;
@ -280,6 +282,8 @@ Queue.propTypes = {
isPopulated: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired,
error: PropTypes.object, error: PropTypes.object,
items: PropTypes.arrayOf(PropTypes.object).isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired,
isArtistFetching: PropTypes.bool.isRequired,
isArtistPopulated: PropTypes.bool.isRequired,
isAlbumsFetching: PropTypes.bool.isRequired, isAlbumsFetching: PropTypes.bool.isRequired,
isAlbumsPopulated: PropTypes.bool.isRequired, isAlbumsPopulated: PropTypes.bool.isRequired,
albumsError: PropTypes.object, albumsError: PropTypes.object,

@ -15,12 +15,15 @@ import Queue from './Queue';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.artist,
(state) => state.albums, (state) => state.albums,
(state) => state.queue.options, (state) => state.queue.options,
(state) => state.queue.paged, (state) => state.queue.paged,
createCommandExecutingSelector(commandNames.REFRESH_MONITORED_DOWNLOADS), createCommandExecutingSelector(commandNames.REFRESH_MONITORED_DOWNLOADS),
(albums, options, queue, isRefreshMonitoredDownloadsExecuting) => { (artist, albums, options, queue, isRefreshMonitoredDownloadsExecuting) => {
return { return {
isArtistFetching: artist.isFetching,
isArtistPopulated: artist.isPopulated,
isAlbumsFetching: albums.isFetching, isAlbumsFetching: albums.isFetching,
isAlbumsPopulated: albums.isPopulated, isAlbumsPopulated: albums.isPopulated,
albumsError: albums.error, albumsError: albums.error,

@ -113,6 +113,8 @@ class CutoffUnmet extends Component {
isPopulated, isPopulated,
error, error,
items, items,
isArtistFetching,
isArtistPopulated,
selectedFilterKey, selectedFilterKey,
filters, filters,
columns, columns,
@ -130,6 +132,9 @@ class CutoffUnmet extends Component {
isConfirmSearchAllCutoffUnmetModalOpen isConfirmSearchAllCutoffUnmetModalOpen
} = this.state; } = this.state;
const isAllPopulated = isPopulated && isArtistPopulated;
const isAnyFetching = isFetching || isArtistFetching;
const itemsSelected = !!this.getSelectedIds().length; const itemsSelected = !!this.getSelectedIds().length;
const isShowingMonitored = getMonitoredValue(this.props); const isShowingMonitored = getMonitoredValue(this.props);
@ -178,26 +183,26 @@ class CutoffUnmet extends Component {
<PageContentBody> <PageContentBody>
{ {
isFetching && !isPopulated && isAnyFetching && !isAllPopulated &&
<LoadingIndicator /> <LoadingIndicator />
} }
{ {
!isFetching && error && !isAnyFetching && error &&
<div> <div>
Error fetching cutoff unmet Error fetching cutoff unmet
</div> </div>
} }
{ {
isPopulated && !error && !items.length && isAllPopulated && !error && !items.length &&
<div> <div>
No cutoff unmet items No cutoff unmet items
</div> </div>
} }
{ {
isPopulated && !error && !!items.length && isAllPopulated && !error && !!items.length &&
<div> <div>
<Table <Table
columns={columns} columns={columns}
@ -261,6 +266,8 @@ CutoffUnmet.propTypes = {
isPopulated: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired,
error: PropTypes.object, error: PropTypes.object,
items: PropTypes.arrayOf(PropTypes.object).isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired,
isArtistFetching: PropTypes.bool.isRequired,
isArtistPopulated: PropTypes.bool.isRequired,
selectedFilterKey: PropTypes.string.isRequired, selectedFilterKey: PropTypes.string.isRequired,
filters: PropTypes.arrayOf(PropTypes.object).isRequired, filters: PropTypes.arrayOf(PropTypes.object).isRequired,
columns: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired,

@ -17,10 +17,13 @@ import CutoffUnmet from './CutoffUnmet';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.wanted.cutoffUnmet, (state) => state.wanted.cutoffUnmet,
(state) => state.artist,
createCommandExecutingSelector(commandNames.CUTOFF_UNMET_ALBUM_SEARCH), createCommandExecutingSelector(commandNames.CUTOFF_UNMET_ALBUM_SEARCH),
(cutoffUnmet, isSearchingForCutoffUnmetAlbums) => { (cutoffUnmet, artist, isSearchingForCutoffUnmetAlbums) => {
return { return {
isArtistFetching: artist.isFetching,
isArtistPopulated: artist.isPopulated,
isSearchingForCutoffUnmetAlbums, isSearchingForCutoffUnmetAlbums,
isSaving: cutoffUnmet.items.filter((m) => m.isSaving).length > 1, isSaving: cutoffUnmet.items.filter((m) => m.isSaving).length > 1,
...cutoffUnmet ...cutoffUnmet

@ -122,6 +122,8 @@ class Missing extends Component {
isPopulated, isPopulated,
error, error,
items, items,
isArtistFetching,
isArtistPopulated,
selectedFilterKey, selectedFilterKey,
filters, filters,
columns, columns,
@ -140,6 +142,9 @@ class Missing extends Component {
isInteractiveImportModalOpen isInteractiveImportModalOpen
} = this.state; } = this.state;
const isAllPopulated = isPopulated && isArtistPopulated;
const isAnyFetching = isFetching || isArtistFetching;
const itemsSelected = !!this.getSelectedIds().length; const itemsSelected = !!this.getSelectedIds().length;
const isShowingMonitored = getMonitoredValue(this.props); const isShowingMonitored = getMonitoredValue(this.props);
@ -195,26 +200,26 @@ class Missing extends Component {
<PageContentBody> <PageContentBody>
{ {
isFetching && !isPopulated && isAnyFetching && !isAllPopulated &&
<LoadingIndicator /> <LoadingIndicator />
} }
{ {
!isFetching && error && !isAnyFetching && error &&
<div> <div>
Error fetching missing items Error fetching missing items
</div> </div>
} }
{ {
isPopulated && !error && !items.length && isAllPopulated && !error && !items.length &&
<div> <div>
No missing items No missing items
</div> </div>
} }
{ {
isPopulated && !error && !!items.length && isAllPopulated && !error && !!items.length &&
<div> <div>
<Table <Table
columns={columns} columns={columns}
@ -284,6 +289,8 @@ Missing.propTypes = {
isPopulated: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired,
error: PropTypes.object, error: PropTypes.object,
items: PropTypes.arrayOf(PropTypes.object).isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired,
isArtistFetching: PropTypes.bool.isRequired,
isArtistPopulated: PropTypes.bool.isRequired,
selectedFilterKey: PropTypes.string.isRequired, selectedFilterKey: PropTypes.string.isRequired,
filters: PropTypes.arrayOf(PropTypes.object).isRequired, filters: PropTypes.arrayOf(PropTypes.object).isRequired,
columns: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired,

@ -16,10 +16,13 @@ import Missing from './Missing';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.wanted.missing, (state) => state.wanted.missing,
(state) => state.artist,
createCommandExecutingSelector(commandNames.MISSING_ALBUM_SEARCH), createCommandExecutingSelector(commandNames.MISSING_ALBUM_SEARCH),
(missing, isSearchingForMissingAlbums) => { (missing, artist, isSearchingForMissingAlbums) => {
return { return {
isArtistFetching: artist.isFetching,
isArtistPopulated: artist.isPopulated,
isSearchingForMissingAlbums, isSearchingForMissingAlbums,
isSaving: missing.items.filter((m) => m.isSaving).length > 1, isSaving: missing.items.filter((m) => m.isSaving).length > 1,
...missing ...missing

Loading…
Cancel
Save