From 38884e25d8e0d76ebf2cfde975e28ad5a18c3c3e Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Tue, 26 Sep 2023 18:40:01 +0530 Subject: [PATCH] Add video quality filters #176 --- src/routes/library/index.jsx | 273 ++++++++++++++++++++----- src/routes/library/library.module.scss | 4 +- 2 files changed, 230 insertions(+), 47 deletions(-) diff --git a/src/routes/library/index.jsx b/src/routes/library/index.jsx index 0a76dbf..cb37aa3 100644 --- a/src/routes/library/index.jsx +++ b/src/routes/library/index.jsx @@ -123,38 +123,6 @@ const LibraryView = () => { const [isFavorite, setisFavorite] = useState(false); const [isLiked, setIsLiked] = useState(false); const [isUnliked, setIsUnliked] = useState(false); - const availableWatchStatus = [ - { - title: "Played", - value: false, - state: (val) => setIsPlayed(val), - }, - { - title: "Unplayed", - value: false, - state: (val) => setIsUnPlayed(val), - }, - { - title: "Resumable", - value: false, - state: (val) => setIsResumable(val), - }, - { - title: "Favourite", - value: false, - state: (val) => setisFavorite(val), - }, - { - title: "Liked", - value: false, - state: (val) => setIsLiked(val), - }, - { - title: "UnLiked", - value: false, - state: (val) => setIsUnliked(val), - }, - ]; const [hasSubtitles, setHasSubtitles] = useState(false); const [hasTrailer, setHasTrailer] = useState(false); @@ -308,6 +276,8 @@ const LibraryView = () => { const [filterArray, setFilterArray] = useState([]); + const [videoTypes, setVideoTypes] = useState([]); + const fetchLibItems = async (libraryId) => { let result; if (currentViewType == "MusicArtist") { @@ -371,7 +341,7 @@ const LibraryView = () => { hasSpecialFeature: hasSpecialFeature ? true : undefined, hasThemeSong: hasThemeSong ? true : undefined, hasThemeVideo: hasThemeVideo ? true : undefined, - videoTypes: [isBluRay && "BluRay", isDVD && "Dvd"], + videoTypes: videoTypes, isHd: isHD ? true : undefined, is4K: is4K ? true : undefined, is3D: is3D ? true : undefined, @@ -401,7 +371,7 @@ const LibraryView = () => { hasThemeSong: hasThemeSong, hasThemeVideo: hasThemeVideo, }, - qualityFIlters: { + qualityFilters: { isBluRay: isBluRay, isDVD: isDVD, isHD: isHD, @@ -451,14 +421,6 @@ const LibraryView = () => { items.refetch(); }; - const disablePaginationViews = [ - "MusicArtist", - "Person", - "Genre", - "MusicGenre", - "Studio", - ]; - const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]); useState(() => { @@ -949,6 +911,227 @@ const LibraryView = () => { /> + {currentLib.data.Items[0] + .CollectionType == + "movies" && ( + + + } + > + + Quality + + + + { + setIsBluRay( + e + .target + .checked, + ); + if ( + e + .target + .checked + ) { + setVideoTypes( + ( + state, + ) => [ + ...state, + "BluRay", + ], + ); + } else { + setVideoTypes( + filterArray.filter( + ( + val, + ) => + val != + "BluRay", + ), + ); + } + }} + /> + } + labelPlacement="start" + componentsProps={{ + typography: + { + style: { + justifySelf: + "start", + }, + }, + }} + /> + { + setIsDVD( + e + .target + .checked, + ); + if ( + e + .target + .checked + ) { + setVideoTypes( + ( + state, + ) => [ + ...state, + "Dvd", + ], + ); + } else { + setVideoTypes( + filterArray.filter( + ( + val, + ) => + val != + "Dvd", + ), + ); + } + }} + /> + } + labelPlacement="start" + componentsProps={{ + typography: + { + style: { + justifySelf: + "start", + }, + }, + }} + /> + { + setIsHD( + e + .target + .checked, + ); + }} + /> + } + labelPlacement="start" + componentsProps={{ + typography: + { + style: { + justifySelf: + "start", + }, + }, + }} + /> + { + setIs4K( + e + .target + .checked, + ); + }} + /> + } + labelPlacement="start" + componentsProps={{ + typography: + { + style: { + justifySelf: + "start", + }, + }, + }} + /> + { + setIs3D( + e + .target + .checked, + ); + }} + /> + } + labelPlacement="start" + componentsProps={{ + typography: + { + style: { + justifySelf: + "start", + }, + }, + }} + /> + + + )} )} @@ -1100,7 +1283,7 @@ const LibraryView = () => { hasThemeVideo: hasThemeVideo, }, - qualityFIlters: { + qualityFilters: { isBluRay: isBluRay, isDVD: isDVD, @@ -1252,9 +1435,7 @@ const LibraryView = () => { )} - {!items.isLoading && - !disablePaginationViews.includes(currentViewType) && - items.isSuccess && + {items.isSuccess && items.data.TotalRecordCount > maxDisplayItems && (