From edf9831a797e64be97e1d0653e6845acb41a366d Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Mon, 25 Sep 2023 21:32:57 +0530 Subject: [PATCH] Improve Card display in Library Page #176 --- src/components/card/card.jsx | 4 +- src/routes/library/index.jsx | 97 +++++++++++++++++++++++++++++------- src/routes/series/index.jsx | 8 +-- 3 files changed, 86 insertions(+), 23 deletions(-) diff --git a/src/components/card/card.jsx b/src/components/card/card.jsx index 81a4f40..296d0c9 100644 --- a/src/components/card/card.jsx +++ b/src/components/card/card.jsx @@ -216,7 +216,7 @@ export const Card = ({ @@ -225,7 +225,7 @@ export const Card = ({ {item.UserData?.PlaybackPositionTicks > 0 && ( { }); const [sortAscending, setSortAscending] = useState(true); - const [sortBy, setSortBy] = useState("SortName"); + const [sortBy, setSortBy] = useState(""); /** * @typedef {{title: string, value: string}} SortObject @@ -199,8 +199,13 @@ const LibraryView = () => { { title: "3D", value: false, state: (val) => setIs3D(val) }, ]; - const [currentViewType, setCurrentViewType] = useState(undefined); + const [currentViewType, setCurrentViewType] = useState(""); + + /** + * @type {[SortObject[], Function]} + */ const [viewType, setViewType] = useState([]); + useEffect(() => { if (currentLib.isSuccess) { if (currentLib.data.Items[0].CollectionType == "movies") { @@ -306,26 +311,36 @@ const LibraryView = () => { result = await getArtistsApi(window.api).getAlbumArtists({ userId: user.data.Id, parentId: libraryId, + startIndex: maxDisplayItems * (page - 1), + limit: maxDisplayItems, }); } else if (currentViewType == "Person") { result = await getPersonsApi(window.api).getPersons({ userId: user.data.Id, personTypes: ["Actor"], + startIndex: maxDisplayItems * (page - 1), + limit: maxDisplayItems, }); } else if (currentViewType == "Genre") { result = await getGenresApi(window.api).getGenres({ userId: user.data.Id, parentId: libraryId, + startIndex: maxDisplayItems * (page - 1), + limit: maxDisplayItems, }); } else if (currentViewType == "MusicGenre") { result = await getMusicGenresApi(window.api).getMusicGenres({ userId: user.data.Id, parentId: libraryId, + startIndex: maxDisplayItems * (page - 1), + limit: maxDisplayItems, }); } else if (currentViewType == "Studio") { result = await getStudiosApi(window.api).getStudios({ userId: user.data.Id, parentId: libraryId, + startIndex: maxDisplayItems * (page - 1), + limit: maxDisplayItems, }); } else { result = await getItemsApi(window.api).getItems({ @@ -509,25 +524,55 @@ const LibraryView = () => {
- - setSortAscending(!sortAscending) - } - > - {sortAscending ? ( - - ) : ( - - )} - + {disabledSortViews.includes(currentViewType) ? ( + <> + ) : ( + <> + + setSortAscending( + !sortAscending, + ) + } + > + {sortAscending ? ( + + ) : ( + + )} + + + + {sortByData.map( + (option, index) => ( + + {option.title} + + ), + )} + + + )} + setCurrentViewType(e.target.value) + } size="small" > - {sortByData.map((option, index) => ( + {viewType.map((option, index) => ( { }` : item.ProductionYear } + disableOverlay={ + item.Type == + BaseItemKind.Person || + item.Type == + BaseItemKind.MusicAlbum || + item.Type == + BaseItemKind.Genre || + item.Type == + BaseItemKind.MusicGenre || + item.Type == + BaseItemKind.Studio + } cardType={ item.Type == BaseItemKind.MusicAlbum || item.Type == - BaseItemKind.Audio + BaseItemKind.Audio || + item.Type == + BaseItemKind.Genre || + item.Type == + BaseItemKind.MusicGenre || + item.Type == + BaseItemKind.Studio ? "square" : "portrait" } diff --git a/src/routes/series/index.jsx b/src/routes/series/index.jsx index acb8ac8..7a9b41f 100644 --- a/src/routes/series/index.jsx +++ b/src/routes/series/index.jsx @@ -386,15 +386,15 @@ const SeriesTitlePage = () => { "translateY(10px)", opacity: 0, }} - animate={{ + whileInView={{ opacity: 1, transform: "translateY(0px)", }} + viewport={{ + once: true, + }} transition={{ - delay: - index * - 0.05, duration: 0.2, ease: "backInOut", }}