Fixed: Removed unnecessary author data from book endpoint

This commit is contained in:
ta264
2022-05-26 21:51:37 +01:00
parent ce58e6ecdb
commit a59706ceb4
16 changed files with 190 additions and 49 deletions
@@ -5,6 +5,7 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import * as commandNames from 'Commands/commandNames';
import { executeCommand } from 'Store/Actions/commandActions';
import createBookAuthorSelector from 'Store/Selectors/createBookAuthorSelector';
import createBookQualityProfileSelector from 'Store/Selectors/createBookQualityProfileSelector';
import createBookSelector from 'Store/Selectors/createBookSelector';
import createExecutingCommandsSelector from 'Store/Selectors/createExecutingCommandsSelector';
@@ -32,11 +33,13 @@ function selectShowSearchAction() {
function createMapStateToProps() {
return createSelector(
createBookSelector(),
createBookAuthorSelector(),
createBookQualityProfileSelector(),
selectShowSearchAction(),
createExecutingCommandsSelector(),
(
book,
author,
qualityProfile,
showSearchAction,
executingCommands
@@ -54,7 +57,7 @@ function createMapStateToProps() {
const isRefreshingBook = executingCommands.some((command) => {
return (
(command.name === commandNames.REFRESH_AUTHOR &&
command.body.authorId === book.author.id) ||
command.body.authorId === book.authorId) ||
(command.name === commandNames.REFRESH_BOOK &&
command.body.bookId === book.id)
);
@@ -63,7 +66,7 @@ function createMapStateToProps() {
const isSearchingBook = executingCommands.some((command) => {
return (
(command.name === commandNames.AUTHOR_SEARCH &&
command.body.authorId === book.author.id) ||
command.body.authorId === book.authorId) ||
(command.name === commandNames.BOOK_SEARCH &&
command.body.bookIds.includes(book.id))
);
@@ -71,6 +74,7 @@ function createMapStateToProps() {
return {
...book,
author,
qualityProfile,
showSearchAction,
isRefreshingBook,
@@ -12,6 +12,7 @@ import SpinnerIconButton from 'Components/Link/SpinnerIconButton';
import { icons } from 'Helpers/Props';
import dimensions from 'Styles/Variables/dimensions';
import fonts from 'Styles/Variables/fonts';
import createAjaxRequest from 'Utilities/createAjaxRequest';
import stripHtml from 'Utilities/String/stripHtml';
import translate from 'Utilities/String/translate';
import BookIndexOverviewInfo from './BookIndexOverviewInfo';
@@ -42,10 +43,26 @@ class BookIndexOverview extends Component {
this.state = {
isEditAuthorModalOpen: false,
isDeleteAuthorModalOpen: false
isDeleteAuthorModalOpen: false,
overview: ''
};
}
componentDidMount() {
const { id } = this.props;
// Note that this component is lazy loaded by the virtualised view.
// We want to avoid storing overviews for *all* books which is
// why it's not put into the redux store
const promise = createAjaxRequest({
url: `/book/${id}/overview`
}).request;
promise.done((data) => {
this.setState({ overview: data.overview });
});
}
//
// Listeners
@@ -84,7 +101,6 @@ class BookIndexOverview extends Component {
const {
id,
title,
overview,
monitored,
titleSlug,
nextAiring,
@@ -118,6 +134,7 @@ class BookIndexOverview extends Component {
} = statistics;
const {
overview,
isEditAuthorModalOpen,
isDeleteAuthorModalOpen
} = this.state;
@@ -267,7 +284,6 @@ class BookIndexOverview extends Component {
BookIndexOverview.propTypes = {
id: PropTypes.number.isRequired,
title: PropTypes.string.isRequired,
overview: PropTypes.string.isRequired,
monitored: PropTypes.bool.isRequired,
titleSlug: PropTypes.string.isRequired,
nextAiring: PropTypes.string,