From 472da10149ea5f07d9d62aeef1c079f719479ea6 Mon Sep 17 00:00:00 2001 From: ta264 Date: Thu, 23 Dec 2021 21:41:43 +0000 Subject: [PATCH] Fixed: Fix book index footer stats Fixes #1405 Fixes #1407 --- frontend/src/Book/Index/BookIndexFooter.js | 42 ++++++------------- .../Book/Index/BookIndexFooterConnector.js | 18 ++++---- 2 files changed, 23 insertions(+), 37 deletions(-) diff --git a/frontend/src/Book/Index/BookIndexFooter.js b/frontend/src/Book/Index/BookIndexFooter.js index d5b64ea04..ff0ee3d4c 100644 --- a/frontend/src/Book/Index/BookIndexFooter.js +++ b/frontend/src/Book/Index/BookIndexFooter.js @@ -14,16 +14,18 @@ class BookIndexFooter extends PureComponent { // Render render() { - const { author } = this.props; - const count = author.length; + const { book } = this.props; + const count = book.length; let books = 0; let bookFiles = 0; - let ended = 0; - let continuing = 0; let monitored = 0; let totalFileSize = 0; - author.forEach((s) => { + const authors = new Set(); + + book.forEach((s) => { + authors.add(s.authorId); + const { statistics = {} } = s; const { @@ -35,12 +37,6 @@ class BookIndexFooter extends PureComponent { books += bookCount; bookFiles += bookFileCount; - if (s.status === 'ended') { - ended++; - } else { - continuing++; - } - if (s.monitored) { monitored++; } @@ -104,23 +100,6 @@ class BookIndexFooter extends PureComponent {
- - - - - - - - + + { - return authors.items.map((s) => { + createClientSideCollectionSelector('books', 'bookIndex'), + (books) => { + return books.items.map((s) => { const { + authorId, monitored, status, statistics } = s; return { + authorId, monitored, status, statistics @@ -25,19 +27,19 @@ function createUnoptimizedSelector() { ); } -function createAuthorSelector() { +function createBookSelector() { return createDeepEqualSelector( createUnoptimizedSelector(), - (author) => author + (book) => book ); } function createMapStateToProps() { return createSelector( - createAuthorSelector(), - (author) => { + createBookSelector(), + (book) => { return { - author + book }; } );