mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-20 21:54:25 -04:00
New: Add index views for all books
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { createSelector, createSelectorCreator, defaultMemoize } from 'reselect';
|
||||
import hasDifferentItemsOrOrder from 'Utilities/Object/hasDifferentItemsOrOrder';
|
||||
import createClientSideCollectionSelector from './createClientSideCollectionSelector';
|
||||
|
||||
function createUnoptimizedSelector(uiSection) {
|
||||
return createSelector(
|
||||
createClientSideCollectionSelector('books', uiSection),
|
||||
(books) => {
|
||||
const items = books.items.map((s) => {
|
||||
const {
|
||||
id,
|
||||
title,
|
||||
authorTitle
|
||||
} = s;
|
||||
|
||||
return {
|
||||
id,
|
||||
title,
|
||||
authorTitle
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
...books,
|
||||
items
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function bookListEqual(a, b) {
|
||||
return hasDifferentItemsOrOrder(a, b);
|
||||
}
|
||||
|
||||
const createBookEqualSelector = createSelectorCreator(
|
||||
defaultMemoize,
|
||||
bookListEqual
|
||||
);
|
||||
|
||||
function createBookClientSideCollectionItemsSelector(uiSection) {
|
||||
return createBookEqualSelector(
|
||||
createUnoptimizedSelector(uiSection),
|
||||
(book) => book
|
||||
);
|
||||
}
|
||||
|
||||
export default createBookClientSideCollectionItemsSelector;
|
||||
Reference in New Issue
Block a user