Fixed: Error refreshing page on Activity/Wanted

This commit is contained in:
ta264 2020-08-18 23:31:00 +01:00
parent cc0fea2aab
commit bb409b9929
10 changed files with 65 additions and 21 deletions

View file

@ -22,6 +22,8 @@ class Blacklist extends Component {
const { const {
isFetching, isFetching,
isPopulated, isPopulated,
isAuthorFetching,
isAuthorPopulated,
error, error,
items, items,
columns, columns,
@ -31,6 +33,9 @@ class Blacklist extends Component {
...otherProps ...otherProps
} = this.props; } = this.props;
const isAllPopulated = isPopulated && isAuthorPopulated;
const isAnyFetching = isFetching || isAuthorFetching;
return ( return (
<PageContent title="Blacklist"> <PageContent title="Blacklist">
<PageToolbar> <PageToolbar>
@ -58,24 +63,24 @@ class Blacklist extends Component {
<PageContentBodyConnector> <PageContentBodyConnector>
{ {
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 = {
isAuthorFetching: PropTypes.bool.isRequired,
isAuthorPopulated: 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,

View file

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

View file

@ -51,6 +51,8 @@ class History extends Component {
selectedFilterKey, selectedFilterKey,
filters, filters,
totalRecords, totalRecords,
isAuthorFetching,
isAuthorPopulated,
isBooksFetching, isBooksFetching,
isBooksPopulated, isBooksPopulated,
booksError, booksError,
@ -59,8 +61,8 @@ class History extends Component {
...otherProps ...otherProps
} = this.props; } = this.props;
const isFetchingAny = isFetching || isBooksFetching; const isFetchingAny = isFetching || isAuthorFetching || isBooksFetching;
const isAllPopulated = isPopulated && (isBooksPopulated || !items.length); const isAllPopulated = isPopulated && ((isAuthorPopulated && isBooksPopulated) || !items.length);
const hasError = error || booksError; const hasError = error || booksError;
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,
isAuthorFetching: PropTypes.bool.isRequired,
isAuthorPopulated: PropTypes.bool.isRequired,
isBooksFetching: PropTypes.bool.isRequired, isBooksFetching: PropTypes.bool.isRequired,
isBooksPopulated: PropTypes.bool.isRequired, isBooksPopulated: PropTypes.bool.isRequired,
booksError: PropTypes.object, booksError: PropTypes.object,

View file

@ -13,9 +13,12 @@ import History from './History';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.history, (state) => state.history,
(state) => state.authors,
(state) => state.books, (state) => state.books,
(history, books) => { (history, authors, books) => {
return { return {
isAuthorFetching: authors.isFetching,
isAuthorPopulated: authors.isPopulated,
isBooksFetching: books.isFetching, isBooksFetching: books.isFetching,
isBooksPopulated: books.isPopulated, isBooksPopulated: books.isPopulated,
booksError: books.error, booksError: books.error,

View file

@ -125,6 +125,8 @@ class Queue extends Component {
isPopulated, isPopulated,
error, error,
items, items,
isAuthorFetching,
isAuthorPopulated,
isBooksFetching, isBooksFetching,
isBooksPopulated, isBooksPopulated,
booksError, booksError,
@ -145,8 +147,8 @@ class Queue extends Component {
isPendingSelected isPendingSelected
} = this.state; } = this.state;
const isRefreshing = isFetching || isBooksFetching || isRefreshMonitoredDownloadsExecuting; const isRefreshing = isFetching || isAuthorFetching || isBooksFetching || isRefreshMonitoredDownloadsExecuting;
const isAllPopulated = isPopulated && (isBooksPopulated || !items.length || items.every((e) => !e.bookId)); const isAllPopulated = isPopulated && ((isAuthorPopulated && isBooksPopulated) || !items.length || items.every((e) => !e.bookId));
const hasError = error || booksError; const hasError = error || booksError;
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,
isAuthorFetching: PropTypes.bool.isRequired,
isAuthorPopulated: PropTypes.bool.isRequired,
isBooksFetching: PropTypes.bool.isRequired, isBooksFetching: PropTypes.bool.isRequired,
isBooksPopulated: PropTypes.bool.isRequired, isBooksPopulated: PropTypes.bool.isRequired,
booksError: PropTypes.object, booksError: PropTypes.object,

View file

@ -15,12 +15,15 @@ import Queue from './Queue';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.authors,
(state) => state.books, (state) => state.books,
(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),
(books, options, queue, isRefreshMonitoredDownloadsExecuting) => { (authors, books, options, queue, isRefreshMonitoredDownloadsExecuting) => {
return { return {
isAuthorFetching: authors.isFetching,
isAuthorPopulated: authors.isPopulated,
isBooksFetching: books.isFetching, isBooksFetching: books.isFetching,
isBooksPopulated: books.isPopulated, isBooksPopulated: books.isPopulated,
booksError: books.error, booksError: books.error,

View file

@ -113,6 +113,8 @@ class CutoffUnmet extends Component {
isPopulated, isPopulated,
error, error,
items, items,
isAuthorFetching,
isAuthorPopulated,
selectedFilterKey, selectedFilterKey,
filters, filters,
columns, columns,
@ -130,6 +132,9 @@ class CutoffUnmet extends Component {
isConfirmSearchAllCutoffUnmetModalOpen isConfirmSearchAllCutoffUnmetModalOpen
} = this.state; } = this.state;
const isAllPopulated = isPopulated && isAuthorPopulated;
const isAnyFetching = isFetching || isAuthorFetching;
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 {
<PageContentBodyConnector> <PageContentBodyConnector>
{ {
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,
isAuthorFetching: PropTypes.bool.isRequired,
isAuthorPopulated: 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,

View file

@ -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.authors,
createCommandExecutingSelector(commandNames.CUTOFF_UNMET_BOOK_SEARCH), createCommandExecutingSelector(commandNames.CUTOFF_UNMET_BOOK_SEARCH),
(cutoffUnmet, isSearchingForCutoffUnmetBooks) => { (cutoffUnmet, authors, isSearchingForCutoffUnmetBooks) => {
return { return {
isAuthorFetching: authors.isFetching,
isAuthorPopulated: authors.isPopulated,
isSearchingForCutoffUnmetBooks, isSearchingForCutoffUnmetBooks,
isSaving: cutoffUnmet.items.filter((m) => m.isSaving).length > 1, isSaving: cutoffUnmet.items.filter((m) => m.isSaving).length > 1,
...cutoffUnmet ...cutoffUnmet

View file

@ -122,6 +122,8 @@ class Missing extends Component {
isPopulated, isPopulated,
error, error,
items, items,
isAuthorFetching,
isAuthorPopulated,
selectedFilterKey, selectedFilterKey,
filters, filters,
columns, columns,
@ -140,6 +142,9 @@ class Missing extends Component {
isInteractiveImportModalOpen isInteractiveImportModalOpen
} = this.state; } = this.state;
const isAllPopulated = isPopulated && isAuthorPopulated;
const isAnyFetching = isFetching || isAuthorFetching;
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 {
<PageContentBodyConnector> <PageContentBodyConnector>
{ {
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,
isAuthorFetching: PropTypes.bool.isRequired,
isAuthorPopulated: 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,

View file

@ -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.authors,
createCommandExecutingSelector(commandNames.MISSING_BOOK_SEARCH), createCommandExecutingSelector(commandNames.MISSING_BOOK_SEARCH),
(missing, isSearchingForMissingBooks) => { (missing, authors, isSearchingForMissingBooks) => {
return { return {
isAuthorFetching: authors.isFetching,
isAuthorPopulated: authors.isPopulated,
isSearchingForMissingBooks, isSearchingForMissingBooks,
isSaving: missing.items.filter((m) => m.isSaving).length > 1, isSaving: missing.items.filter((m) => m.isSaving).length > 1,
...missing ...missing