New: Search bar searches books as well as authors

This commit is contained in:
ta264
2021-09-01 21:04:39 +01:00
parent ba9f618405
commit c9cb0a9774
7 changed files with 175 additions and 56 deletions
@@ -21,7 +21,8 @@ function createCleanAuthorSelector() {
} = author;
return {
authorName,
type: 'author',
name: authorName,
sortName,
titleSlug,
images,
@@ -40,12 +41,41 @@ function createCleanAuthorSelector() {
);
}
function createCleanBookSelector() {
return createSelector(
(state) => state.books.items,
(allBooks) => {
return allBooks.map((book) => {
const {
title,
images,
titleSlug
} = book;
return {
type: 'book',
name: title,
sortName: title,
titleSlug,
images,
tags: []
};
});
}
);
}
function createMapStateToProps() {
return createDeepEqualSelector(
createCleanAuthorSelector(),
(authors) => {
createCleanBookSelector(),
(authors, books) => {
const items = [
...authors,
...books
];
return {
authors
items
};
}
);
@@ -57,6 +87,10 @@ function createMapDispatchToProps(dispatch, props) {
dispatch(push(`${window.Readarr.urlBase}/author/${titleSlug}`));
},
onGoToBook(titleSlug) {
dispatch(push(`${window.Readarr.urlBase}/book/${titleSlug}`));
},
onGoToAddNewAuthor(query) {
dispatch(push(`${window.Readarr.urlBase}/add/search?term=${encodeURIComponent(query)}`));
}