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
+11 -4
View File
@@ -22,6 +22,8 @@ class Blacklist extends Component {
const {
isFetching,
isPopulated,
isAuthorFetching,
isAuthorPopulated,
error,
items,
columns,
@@ -31,6 +33,9 @@ class Blacklist extends Component {
...otherProps
} = this.props;
const isAllPopulated = isPopulated && isAuthorPopulated;
const isAnyFetching = isFetching || isAuthorFetching;
return (
<PageContent title="Blacklist">
<PageToolbar>
@@ -58,24 +63,24 @@ class Blacklist extends Component {
<PageContentBodyConnector>
{
isFetching && !isPopulated &&
isAnyFetching && !isAllPopulated &&
<LoadingIndicator />
}
{
!isFetching && !!error &&
!isAnyFetching && !!error &&
<div>Unable to load blacklist</div>
}
{
isPopulated && !error && !items.length &&
isAllPopulated && !error && !items.length &&
<div>
No history blacklist
</div>
}
{
isPopulated && !error && !!items.length &&
isAllPopulated && !error && !!items.length &&
<div>
<Table
columns={columns}
@@ -110,6 +115,8 @@ class Blacklist extends Component {
}
Blacklist.propTypes = {
isAuthorFetching: PropTypes.bool.isRequired,
isAuthorPopulated: PropTypes.bool.isRequired,
isFetching: PropTypes.bool.isRequired,
isPopulated: PropTypes.bool.isRequired,
error: PropTypes.object,
@@ -13,9 +13,12 @@ import Blacklist from './Blacklist';
function createMapStateToProps() {
return createSelector(
(state) => state.blacklist,
(state) => state.authors,
createCommandExecutingSelector(commandNames.CLEAR_BLACKLIST),
(blacklist, isClearingBlacklistExecuting) => {
(blacklist, authors, isClearingBlacklistExecuting) => {
return {
isAuthorFetching: authors.isFetching,
isAuthorPopulated: authors.isPopulated,
isClearingBlacklistExecuting,
...blacklist
};
+6 -2
View File
@@ -51,6 +51,8 @@ class History extends Component {
selectedFilterKey,
filters,
totalRecords,
isAuthorFetching,
isAuthorPopulated,
isBooksFetching,
isBooksPopulated,
booksError,
@@ -59,8 +61,8 @@ class History extends Component {
...otherProps
} = this.props;
const isFetchingAny = isFetching || isBooksFetching;
const isAllPopulated = isPopulated && (isBooksPopulated || !items.length);
const isFetchingAny = isFetching || isAuthorFetching || isBooksFetching;
const isAllPopulated = isPopulated && ((isAuthorPopulated && isBooksPopulated) || !items.length);
const hasError = error || booksError;
return (
@@ -162,6 +164,8 @@ History.propTypes = {
selectedFilterKey: PropTypes.string.isRequired,
filters: PropTypes.arrayOf(PropTypes.object).isRequired,
totalRecords: PropTypes.number,
isAuthorFetching: PropTypes.bool.isRequired,
isAuthorPopulated: PropTypes.bool.isRequired,
isBooksFetching: PropTypes.bool.isRequired,
isBooksPopulated: PropTypes.bool.isRequired,
booksError: PropTypes.object,
@@ -13,9 +13,12 @@ import History from './History';
function createMapStateToProps() {
return createSelector(
(state) => state.history,
(state) => state.authors,
(state) => state.books,
(history, books) => {
(history, authors, books) => {
return {
isAuthorFetching: authors.isFetching,
isAuthorPopulated: authors.isPopulated,
isBooksFetching: books.isFetching,
isBooksPopulated: books.isPopulated,
booksError: books.error,
+6 -2
View File
@@ -125,6 +125,8 @@ class Queue extends Component {
isPopulated,
error,
items,
isAuthorFetching,
isAuthorPopulated,
isBooksFetching,
isBooksPopulated,
booksError,
@@ -145,8 +147,8 @@ class Queue extends Component {
isPendingSelected
} = this.state;
const isRefreshing = isFetching || isBooksFetching || isRefreshMonitoredDownloadsExecuting;
const isAllPopulated = isPopulated && (isBooksPopulated || !items.length || items.every((e) => !e.bookId));
const isRefreshing = isFetching || isAuthorFetching || isBooksFetching || isRefreshMonitoredDownloadsExecuting;
const isAllPopulated = isPopulated && ((isAuthorPopulated && isBooksPopulated) || !items.length || items.every((e) => !e.bookId));
const hasError = error || booksError;
const selectedIds = this.getSelectedIds();
const selectedCount = selectedIds.length;
@@ -280,6 +282,8 @@ Queue.propTypes = {
isPopulated: PropTypes.bool.isRequired,
error: PropTypes.object,
items: PropTypes.arrayOf(PropTypes.object).isRequired,
isAuthorFetching: PropTypes.bool.isRequired,
isAuthorPopulated: PropTypes.bool.isRequired,
isBooksFetching: PropTypes.bool.isRequired,
isBooksPopulated: PropTypes.bool.isRequired,
booksError: PropTypes.object,
@@ -15,12 +15,15 @@ import Queue from './Queue';
function createMapStateToProps() {
return createSelector(
(state) => state.authors,
(state) => state.books,
(state) => state.queue.options,
(state) => state.queue.paged,
createCommandExecutingSelector(commandNames.REFRESH_MONITORED_DOWNLOADS),
(books, options, queue, isRefreshMonitoredDownloadsExecuting) => {
(authors, books, options, queue, isRefreshMonitoredDownloadsExecuting) => {
return {
isAuthorFetching: authors.isFetching,
isAuthorPopulated: authors.isPopulated,
isBooksFetching: books.isFetching,
isBooksPopulated: books.isPopulated,
booksError: books.error,